This project is read-only.

DotNetLib.BooleanExtensions / BooleanFormatProvider

Variety of helper methods and extensions to assist when dealing with boolean types.

ToString

Allows for custom formatting of a boolean when you need something other than 'true' and 'false'
bool isDiskLoaded = true;
Console.WriteLine(isDiskLoaded.ToString("yn"));
// "Yes" will be output here
isDiskLoaded = false;
Console.WriteLine(isDiskLoaded.ToString("yn"));
// "No" will be output here

bool microsoftIsEvil = false;
Console.WriteLine(string.Format(new BooleanFormatProvider(), "Microsoft is {0:evil|not evil}", microsoftIsEvil));
// "Microsoft is not evil" will be output here

bool pepsiPreference = true;
Console.WriteLine("I like " + pepsiPreference.ToString("Pepsi|Coke"));
// "I like Pepsi" will be output here
Home

Last edited Dec 8, 2008 at 4:26 AM by joshucar, version 1

Comments

No comments yet.