Monday, August 20, 2007

(1,0) to (Yes,No) in C#

One of the minor things which i always required in my work is to convert (1,0) to (yes,no). Usually i used to use "If" conditions, but i found following string formatting method much better and interesting.

string.Format("{0:yes;;no}", 0);
string.Format("{0:yes;;no}", 1);