Serialization
Most of the C# Generics are XML serializable. Dictionary, however, is not. It can be extended with IXmlSerializable.
Most of the C# Generics are XML serializable. Dictionary, however, is not. It can be extended with IXmlSerializable.
public static string Capitalize(this String s)
{
return s.ToCharArray().Aggregate(
string.Empty,
(working, next) =>
{
if (working.Length == 0 && next != ' ')
{
return next.ToString().ToUpper();
}
else if (working.EndsWith(" "))
{
return working + next.ToString().ToUpper();
}
else
{
return working + next.ToString();
}
});
}
public static bool Even(this int i)
{
return (i & 1) == 0;
}
public static bool Odd(this int i)
{
return (i & 1) == 1;
}
////// Replace line breaks with <br /> tags and encode the output. /// ///public static string Nl2br(this HtmlHelper html, string text) { return html.Encode(text).Replace(Environment.NewLine, "<br />"); }