-----------------------------------------------------------
New Message on MumbaiUserGroup
-----------------------------------------------------------
From: Vipul
Message 1 in Discussion
Time and again we write code and our brackets get out of
visual sync, i.e. they no longer appear as a coherent set even though they may
be.<o:p></o:p>
<o:p> </o:p>
In Visual Studio, there is a feature known as Format Document
which will align the code systematically.<o:p></o:p>
<o:p> </o:p>
It can be invoked by the key combination of Ctrl K + Ctrl D<o:p></o:p>
<o:p> </o:p>
Suppose you code looks like<o:p></o:p>
<o:p></o:p>
namespace
LogFileCheck<o:p></o:p>
{<o:p></o:p>
class
Program<o:p></o:p>
{<o:p></o:p>
static
void <u1:place u2:st="on"><st1:place
w:st="on">Main</u1:place></st1:place>(string[]
args)<o:p></o:p>
{<o:p></o:p>
TextReader sr = new
StreamReader("mb20051116_05000600_BAYTRARPT03_k.msn.com_w3svc10000.log",
Encoding.UTF8);<o:p></o:p>
TextWriter writesr = <o:p></o:p>
new
StreamWriter("mb20051116_05000600_BAYTRARPT03_k.msn.com_w3svc10000_csResult.log",
<o:p></o:p>
false, Encoding.UTF8);<o:p></o:p>
while (sr.Peek()<o:p></o:p>
!= -1)<o:p></o:p>
{<o:p></o:p>
string line = sr.ReadLine();<o:p></o:p>
if (Regex.IsMatch(line,
"&di=78")
&& Regex.IsMatch(line,
@"([^,]*,){19}66"))<o:p></o:p>
writesr.WriteLine(line);}<o:p></o:p>
<o:p> </o:p>
sr.Close();<o:p></o:p>
writesr.Close();<o:p></o:p>
}<o:p></o:p>
}<o:p></o:p>
}<o:p></o:p>
<o:p> </o:p>
Press the magic keys Ctrl K
+ Ctrl D
and voila, all your code looks pretty organized as under:<o:p></o:p>
<o:p> </o:p>
namespace
LogFileCheck<o:p></o:p>
{<o:p></o:p>
class
Program<o:p></o:p>
{<o:p></o:p>
static
void <u1:place u2:st="on"><st1:place
w:st="on">Main</u1:place></st1:place>(string[]
args)<o:p></o:p>
{<o:p></o:p>
TextReader sr = new
StreamReader("mb20051116_05000600_BAYTRARPT03_k.msn.com_w3svc10000.log",
Encoding.UTF8);<o:p></o:p>
TextWriter writesr = new
StreamWriter("mb20051116_05000600_BAYTRARPT03_k.msn.com_w3svc10000_csResult.log",
false, Encoding.UTF8);<o:p></o:p>
while (sr.Peek() != -1)<o:p></o:p>
{<o:p></o:p>
string line = sr.ReadLine();<o:p></o:p>
if (Regex.IsMatch(line,
"&di=78")
&& Regex.IsMatch(line,
@"([^,]*,){19}66"))<o:p></o:p>
writesr.WriteLine(line);<o:p></o:p>
}<o:p></o:p>
<o:p> </o:p>
sr.Close();<o:p></o:p>
writesr.Close();<o:p></o:p>
}<o:p></o:p>
}<o:p></o:p>
}<o:p></o:p>
<o:p> </o:p>
Want to format only a small selected section of the dirty
code? Select the area you want to format and press Ctrl K + Ctrl F.<o:p></o:p>
<o:p> </o:p>
This post is aggregated at http://msmvps.com/blogs/vipul/default.aspx
<o:p></o:p>
RSS link: http://msmvps.com/blogs/vipul/rss.aspx<o:p></o:p>
Atom: http://msmvps.com/blogs/vipul/atom.aspx<o:p></o:p>
<o:p> </o:p>
<o:p> </o:p>
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you
received this message by mistake, please click the "Remove" link below. On the
pre-addressed e-mail message that opens, simply click "Send". Your e-mail
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]