Created
March 23, 2011 10:37
-
-
Save SergXIIIth/882923 to your computer and use it in GitHub Desktop.
c# cool string extend
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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