Hi All,
I am still learning c# and was wondering if there is a more elegant way of doing the following. I am suspecting there may be a possiblity of a loop that would ease the extra addition of the if else code. If i needed to add another pattern match
is there a simpler way of doing this?
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; string lastline = ReadLastLine(e.FullPath.ToString());
<span style="color:Blue; bool parsed = <span style="color:Blue; false;
<span style="color:Blue; bool parsed2 = <span style="color:Blue; false;
<span style="color:Blue; bool parsed3 = <span style="color:Blue; false;
parsed = PatternMatch(lastline, <span style="color:#A31515; "(\[Application\])");
parsed2 = PatternMatch(lastline, <span style="color:#A31515; "(\[System\])");
parsed3 = PatternMatch(lastline, <span style="color:#A31515; "(\[DNS\])");
<span style="color:Blue; if (parsed)
{
rtb1.AppendText(DateTime.Now + <span style="color:#A31515; " " + lastline);
}
<span style="color:Blue; else <span style="color:Blue; if (parsed2)
{
rtb3.AppendText(DateTime.Now + <span style="color:#A31515; " " + lastline);
}
<span style="color:Blue; else <span style="color:Blue; if (parsed3)
{
rtb3.AppendText(DateTime.Now + <span style="color:#A31515; " " + lastline);
}
<span style="color:Blue; else
{
rtb2.AppendText(DateTime.Now + <span style="color:#A31515; " " + lastline);
}
[/code]
<hr class="sig http://www.xnagse.com
View the full article
I am still learning c# and was wondering if there is a more elegant way of doing the following. I am suspecting there may be a possiblity of a loop that would ease the extra addition of the if else code. If i needed to add another pattern match
is there a simpler way of doing this?
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; string lastline = ReadLastLine(e.FullPath.ToString());
<span style="color:Blue; bool parsed = <span style="color:Blue; false;
<span style="color:Blue; bool parsed2 = <span style="color:Blue; false;
<span style="color:Blue; bool parsed3 = <span style="color:Blue; false;
parsed = PatternMatch(lastline, <span style="color:#A31515; "(\[Application\])");
parsed2 = PatternMatch(lastline, <span style="color:#A31515; "(\[System\])");
parsed3 = PatternMatch(lastline, <span style="color:#A31515; "(\[DNS\])");
<span style="color:Blue; if (parsed)
{
rtb1.AppendText(DateTime.Now + <span style="color:#A31515; " " + lastline);
}
<span style="color:Blue; else <span style="color:Blue; if (parsed2)
{
rtb3.AppendText(DateTime.Now + <span style="color:#A31515; " " + lastline);
}
<span style="color:Blue; else <span style="color:Blue; if (parsed3)
{
rtb3.AppendText(DateTime.Now + <span style="color:#A31515; " " + lastline);
}
<span style="color:Blue; else
{
rtb2.AppendText(DateTime.Now + <span style="color:#A31515; " " + lastline);
}
[/code]
<hr class="sig http://www.xnagse.com
View the full article