Aug 20, 2015

RePost: Must read MSDN C# programming guide

https://msdn.microsoft.com/en-us/library/67ef8sbd.aspx

Aug 19, 2015

Regex - Match only first occurence

In UTF-8 HTML text like this :

<table>
<tr class="dummy">
First
</tr>
<tr class="foo">
Second
</tr>
</table>
; you want to parse out list of two rows.

First,
Second

To achieve this use non greedy expression ?. Basically after you state what is pattern and how often it occurs by using ? you want to limit search only to first occurence.

Example regex with UTF8 greedy expression:

(?<=tr\sclass="\w+">)+?(?>\P{M}\p{M}*)+?(?:\<\/tr\>)+?
http://stackoverflow.com/questions/2503413/regular-expression-to-stop-at-first-match

Aug 6, 2015

RePost : C# - using statement tips

When using any class that implements IDisposable it is advisable to use using statement.

Now what I didn't know is that using statement is replacement for try finally with call to dispose.

Furthermore call to dispose internally calls Close() for Streams I think.

So using statement is real champion :)

Instead of:

try{

Stream s = new Stream();

}
finally
{
s.Flush();
s.Close();
s.Dispose();
}

Just this:

using ( Stream s = new Stream())
{
}

Important!

Flush() is NOT called automatically !
So using takes care of connections and resources but does not takes care that your data will be flushed from cache.
This makes sense since it primary protects from exceptions and developer should think about Flush().

http://stackoverflow.com/questions/911408/does-stream-dispose-always-call-stream-close-and-stream-flush

TODO Reading list . MSDN Network programming

https://msdn.microsoft.com/en-us/library/4as0wz7t(v=vs.100).aspx

RePost: Naming conventions by Microsoft

Good reading for which I never found time. Yet it is always subject of furious discussion with fellow programmers.

https://msdn.microsoft.com/en-us/library/ms229002(v=vs.110).aspx