Friday, 17 December 2010

Conditional String replacement

Found this by accident when doing some linq, but I think this is a nice standard funtion

var x = "A";
Console.Write(String.Format("HELLO WORLD {0}", x.Length == 1 ? x + "X" : x));


Not sure if this works in other version prior to VS2008

No comments:

Post a Comment