Archive for December, 2009

My Visual Studio Settings

There is my Visual studio settings (Visual studio 2008) : Sam_Exported-2009-12-02
It’s the “ragnarok” theme with a few modifications

More »

C#, check if a string is null or empty

In C# you can check if a string is null or empty in many ways :

string String1 = "testString";
if (String1== null || String1 == "")
{
// …
}
else
{
// …
}

string String1 = "testString";
if (String1 == null || String1.Length==0)
{
// …
}
else
{
// …
}

string String1 = "testString";
if (string.IsNullOrEmpty(String1))
{
// …
}
[...]

More »

How long need a portion of code to be executed ?

Use the Stopwatch object !

using System.Diagnostics;

// …

Stopwatch myStopWatch = Stopwatch.StartNew();

// some code

myStopWatch.Stop();

Console.WriteLine("{0} ms – {1} ticks", myStopWatch.Elapsed.TotalMilliseconds, myStopWatch.ElapsedTicks);

// …

More »