Skip to content

Instantly share code, notes, and snippets.

@SergXIIIth
Created March 23, 2011 10:37
Show Gist options
  • Save SergXIIIth/882923 to your computer and use it in GitHub Desktop.
Save SergXIIIth/882923 to your computer and use it in GitHub Desktop.
c# cool string extend
public static class StringExtentions
{
// example "Controls_Admin_AdminDocument_EditDocumentList load IsPostBack={0}".debug(IsPostBack);
public static void debug(this string str, params object[] args)
{
var args_json = args.Select(a => a.json()).ToArray();
Console.WriteLine("********************************");
Console.WriteLine(str.f(args_json));
Console.WriteLine("********************************");
}
public static string f(this string str, params object[] args)
{
return string.Format(str, args);
}
public static string json(this object obj)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
return serializer.Serialize(obj);
}
public static string line_to_br(this string str)
{
return str + "<strong>123</strong>".Replace("\r\n", "<br/>");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment