------------ StringHelper. cs ------------- using System; using System. collections. generic; using System. linq; using System. text; using System. text. regularExpressions; // steps for declaring the extension method: the class must be static and the method is static. // The first parameter is the extended object, which is marked with this. // When using the extension method, you must ensure that the extension method class is already in the current Code. The extension method of usingnamespace {// The extension method must be a static public static class StringHelper {// The extension method must be static, the first parameter must contain this public static bool IsEmail (this string _ input) {return Regex. isMatch (_ input, @ "^ \ w + @ \ w + \. \ w + $ ");} // Extension Method with multiple parameters // Add the specified public static string Quot (this string _ input, string _ quot) before and after the original string) {return _ quot + _ input + _ quot ;}}------------ Program. cs ------------- using System; Using System. collections. generic; using System. linq; using System. text; namespace Extension Method {class Program {static void Main (string [] args) {string _ myEmail = "abc@163.com "; // here we can directly use the string class Extension Method IsEmail Console. writeLine (_ myEmail. isEmail (); // call the Console of the Extension Method for receiving parameters. writeLine (_ myEmail. quot ("! "); Console. ReadLine ();}}}