This project is read-only.


String Extension

The StringEx Class

String Extension Adds 50+ new methods to System.String, covering a variety of common operations. Most of the method names are self-explaining.


Just simple reference to some other static methods but it enhances your productivity.

This is the code of the Scan method.

public static string Scan(this string str, params object[] args)


      return string.Format(str, args);


Now you don’t have to tediously type such like

string.Format("{0}, {1}, {2}", 0, 1, 2);

 All you need is

"{0}, {1}, {2}".Scan(1, 2, 3);

 The following are examples for other methods.

string test1 = "";

string test2 = " ";

string test3 = "test";

Console.WriteLine(test1.IsNullOrEmpty()); //true

Console.WriteLine(test2.IsNullOrEmpty()); //false

Console.WriteLine(test3.IsNullOrEmpty()); //false

Console.WriteLine(test1.IsNullOrEmptyOrBlank()); //true

Console.WriteLine(test2.IsNullOrEmptyOrBlank()); //true

Console.WriteLine(test3.IsNullOrEmptyOrBlank()); //false;

Console.WriteLine(test3.Copy()); //"test"

Console.WriteLine((new string[] { test1, test2, test3 })

.ToHashSet()); //a hash set





Splits a string into two parts using a char as the separator. For example, split "abcde" by "c" and we will get "ab" and "de".



Adds a new overload that split strings in some special way. Currently you may split a string into ASCII parts and non-ASCII parts.



Splits a string by initials (upper letters) into a string array. For example, “ABigApple” can be split into a string array “A” “Big” “Apple”.



Much like the official Split method but keeps the separator information. For now only char separators are supported.



Spilts a string instance to lines represented by a string array.

Last edited Jul 10, 2012 at 4:20 AM by rivermsfly, version 9


No comments yet.