.NET 4.0 adds several new methods.
1) Enum.HasFlag checks whether a flag field present in the enum instance.
[Flags]
public enum PizzaToppings
{
Onions = 1,
Mushrooms = 2,
Chicken = 4
}
PizzaToppings myToppings = PizzaToppings.Onions |
PizzaToppings.Mushrooms;
Assert.IsFalse( myToppings.HasFlag(PizzaToppings.Chicken),
"Chicken is not expected");
[Test]
public void TestIsNullOrWhiteSpace()
{
string s = " \t ";
Assert.IsTrue( string.IsNullOrWhiteSpace(s),
"tabbed white spaces");
Assert.IsTrue(string.IsNullOrWhiteSpace(null), "Null");
Assert.IsTrue(string.IsNullOrWhiteSpace(""), "Empty");
Assert.IsTrue(string.IsNullOrEmpty(" \t ".Trim()));
}