Showing posts with label Conditional String Replacement. Show all posts
Showing posts with label Conditional String Replacement. Show all posts

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