This project has moved and is read-only. For the latest updates, please go here.

System.String Extension Methods

String.Contains Method

A string extension method that query if this object contains the given value.

Syntax

bool Contains(string @this,string value)

Parameters

@this
The @this to act on.
value
The value.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_Contains
     {
         [TestMethod]
         public void Contains()
         {
             // Type
             string @this = "Fizz";
 
             // Examples
             bool value1 = @this.Contains("f", StringComparison.InvariantCultureIgnoreCase); // return true;
             bool value2 = @this.Contains("f", StringComparison.InvariantCulture); // return false;
 
             // Unit Test
             Assert.IsTrue(value1);
             Assert.IsFalse(value2);
         }
     }
 }
                

String.Contains Method

A string extension method that query if this object contains the given value.

Syntax

bool Contains(string @this,string value,StringComparison comparisonType)

Parameters

@this
The @this to act on.
value
The value.
comparisonType
One of the enumeration values that specifies the rules for the search.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_Contains
     {
         [TestMethod]
         public void Contains()
         {
             // Type
             string @this = "Fizz";
 
             // Examples
             bool value1 = @this.Contains("f", StringComparison.InvariantCultureIgnoreCase); // return true;
             bool value2 = @this.Contains("f", StringComparison.InvariantCulture); // return false;
 
             // Unit Test
             Assert.IsTrue(value1);
             Assert.IsFalse(value2);
         }
     }
 }
                

String.ContainsAll Method

A string extension method that query if '@this' contains all values.

Syntax

bool ContainsAll(string @this,string[] values)

Parameters

@this
The @this to act on.
values
A variable-length parameters list containing values.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_ContainsAll
     {
         [TestMethod]
         public void ContainsAll()
         {
             // Type
             string @this = "Fizz";
 
             // Examples
             bool value1 = @this.ContainsAll("F", "i"); // return true;
             bool value2 = @this.ContainsAll("F", "i", "Buzz"); // return false;
             bool value3 = @this.ContainsAll(StringComparison.InvariantCultureIgnoreCase, "f", "i"); // return true;
             bool value4 = @this.ContainsAll(StringComparison.InvariantCulture, "f", "i"); // return false;
 
             // Unit Test
             Assert.IsTrue(value1);
             Assert.IsFalse(value2);
             Assert.IsTrue(value3);
             Assert.IsFalse(value4);
         }
     }
 }
                

String.ContainsAll Method

A string extension method that query if this object contains the given @this.

Syntax

bool ContainsAll(string @this,StringComparison comparisonType,string[] values)

Parameters

@this
The @this to act on.
comparisonType
Type of the comparison.
values
A variable-length parameters list containing values.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_ContainsAll
     {
         [TestMethod]
         public void ContainsAll()
         {
             // Type
             string @this = "Fizz";
 
             // Examples
             bool value1 = @this.ContainsAll("F", "i"); // return true;
             bool value2 = @this.ContainsAll("F", "i", "Buzz"); // return false;
             bool value3 = @this.ContainsAll(StringComparison.InvariantCultureIgnoreCase, "f", "i"); // return true;
             bool value4 = @this.ContainsAll(StringComparison.InvariantCulture, "f", "i"); // return false;
 
             // Unit Test
             Assert.IsTrue(value1);
             Assert.IsFalse(value2);
             Assert.IsTrue(value3);
             Assert.IsFalse(value4);
         }
     }
 }
                

String.ContainsAny Method

A string extension method that query if '@this' contains any values.

Syntax

bool ContainsAny(string @this,string[] values)

Parameters

@this
The @this to act on.
values
A variable-length parameters list containing values.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_ContainsAny
     {
         [TestMethod]
         public void ContainsAny()
         {
             // Type
             string @this = "Fizz";
 
             // Examples
             bool value1 = @this.ContainsAny("F", "Buzz"); // value = ";
             bool value2 = @this.ContainsAny("Bizz", "Buzz"); // value = ";
             bool value3 = @this.ContainsAny(StringComparison.InvariantCultureIgnoreCase, "f", "Buzz"); // value = ";
             bool value4 = @this.ContainsAny(StringComparison.InvariantCulture, "f", "Buzz"); // value = ";
 
             // Unit Test
             Assert.IsTrue(value1);
             Assert.IsFalse(value2);
             Assert.IsTrue(value3);
             Assert.IsFalse(value4);
         }
     }
 }
                

String.ContainsAny Method

A string extension method that query if '@this' contains any values.

Syntax

bool ContainsAny(string @this,StringComparison comparisonType,string[] values)

Parameters

@this
The @this to act on.
comparisonType
Type of the comparison.
values
A variable-length parameters list containing values.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_ContainsAny
     {
         [TestMethod]
         public void ContainsAny()
         {
             // Type
             string @this = "Fizz";
 
             // Examples
             bool value1 = @this.ContainsAny("F", "Buzz"); // value = ";
             bool value2 = @this.ContainsAny("Bizz", "Buzz"); // value = ";
             bool value3 = @this.ContainsAny(StringComparison.InvariantCultureIgnoreCase, "f", "Buzz"); // value = ";
             bool value4 = @this.ContainsAny(StringComparison.InvariantCulture, "f", "Buzz"); // value = ";
 
             // Unit Test
             Assert.IsTrue(value1);
             Assert.IsFalse(value2);
             Assert.IsTrue(value3);
             Assert.IsFalse(value4);
         }
     }
 }
                

String.DecodeBase64 Method

A string extension method that decode a Base64 String.

Syntax

string DecodeBase64(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_DecodeBase64
     {
         [TestMethod]
         public void DecodeBase64()
         {
             // Type
             string @this = "Rml6eg==";
 
             // Examples
             string value = @this.DecodeBase64(); // return "Fizz";
 
             // Unit Test
             Assert.AreEqual("Fizz", value);
         }
     }
 }
                

String.DecryptRSA Method

A string extension method that decrypt a string.

Syntax

string DecryptRSA(string @this,string key)

Parameters

@this
The @this to act on.
key
The key.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_DecryptRSA
     {
         [TestMethod]
         public void DecryptRSA()
         {
             // Type
             string @this = "7E-24-A5-CF-8E-7A-83-52-90-CA-81-6F-26-04-7C-E6-F4-25-47-26-A9-55-04-83-32-78-1A-C0-E4-5D-90-66-A6-E1-58-59-A8-48-E1-20-21-B9-FE-84-31-53-52-9B-45-E1-B2-93-71-92-DA-29-5B-99-D1-41-19-9C-3E-13-4B-2B-BC-08-94-31-A4-F9-B9-0A-04-2F-C6-78-B1-47-27-11-2C-E6-AF-BF-A8-F2-F3-F6-4E-CB-EB-79-5E-80-C6-A1-0A-D7-7C-F1-16-0E-41-14-4E-76-7E-9E-DD-61-BF-11-5E-62-79-2D-C4-11-D2-F6-3D-7F-DD-87-C4-4E";
 
             // Examples
             string value = @this.DecryptRSA("Buzz"); // return "Fizz";
 
             // Unit Test
             Assert.AreEqual("Fizz", value);
         }
     }
 }
                

String.DeserializeBinary Method

A string extension method that deserialize a string binary as <T>.

Syntax

T DeserializeBinary(string @this)

Parameters

@this
The @this to act on.

Type Parameters

T
Generic type parameter.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System.Collections.Generic;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_DeserializeBinary
     {
         [TestMethod]
         public void DeserializeBinary()
         {
             // Type
             string @this = "AAEAAAD/////AQAAAAAAAAAEAQAAAOIBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuRGljdGlvbmFyeWAyW1tTeXN0ZW0uU3RyaW5nLCBtc2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODldLFtTeXN0ZW0uU3RyaW5nLCBtc2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODldXQQAAAAHVmVyc2lvbghDb21wYXJlcghIYXNoU2l6ZQ1LZXlWYWx1ZVBhaXJzAAMAAwiSAVN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkdlbmVyaWNFcXVhbGl0eUNvbXBhcmVyYDFbW1N5c3RlbS5TdHJpbmcsIG1zY29ybGliLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OV1dCOYBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuS2V5VmFsdWVQYWlyYDJbW1N5c3RlbS5TdHJpbmcsIG1zY29ybGliLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OV0sW1N5c3RlbS5TdHJpbmcsIG1zY29ybGliLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OV1dW10BAAAACQIAAAADAAAACQMAAAAEAgAAAJIBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuR2VuZXJpY0VxdWFsaXR5Q29tcGFyZXJgMVtbU3lzdGVtLlN0cmluZywgbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0AAAAABwMAAAAAAQAAAAEAAAAD5AFTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYy5LZXlWYWx1ZVBhaXJgMltbU3lzdGVtLlN0cmluZywgbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XSxbU3lzdGVtLlN0cmluZywgbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0E/P///+QBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuS2V5VmFsdWVQYWlyYDJbW1N5c3RlbS5TdHJpbmcsIG1zY29ybGliLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OV0sW1N5c3RlbS5TdHJpbmcsIG1zY29ybGliLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OV1dAgAAAANrZXkFdmFsdWUBAQYFAAAABEZpenoGBgAAAARCdXp6Cw==";
 
             // Examples
             var value = @this.DeserializeBinary<Dictionary<string, string>>(); // return new Dictionary<string, string> {{"Fizz", "Buzz"}};
 
             // Unit Test
             Assert.AreEqual("Buzz", value["Fizz"]);
         }
     }
 }
                

String.DeserializeXml Method

A string extension method that deserialize an Xml as <T>.

Syntax

T DeserializeXml(string @this)

Parameters

@this
The @this to act on.

Type Parameters

T
Generic type parameter.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System.Collections.Generic;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_DeserializeXml
     {
         [TestMethod]
         public void DeserializeXml()
         {
             // Type
             string @this = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<ArrayOfString xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\r\n  <string>Fizz</string>\r\n  <string>Buzz</string>\r\n</ArrayOfString>";
 
             // Examples
             var value = @this.DeserializeXml<List<string>>(); // new List<string> {"Fizz", "Buzz"};
 
             // Unit Test
             Assert.AreEqual("Fizz", value[0]);
         }
     }
 }
                

String.EncodeBase64 Method

A string extension method that encode the string to Base64.

Syntax

string EncodeBase64(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_EncodeBase64
     {
         [TestMethod]
         public void EncodeBase64()
         {
             // Type
             string @this = "Fizz";
 
             // Examples
             string value = @this.EncodeBase64(); // return "Rml6eg==";
 
             // Unit Test
             Assert.AreEqual("Rml6eg==", value);
         }
     }
 }
                

String.EncryptRSA Method

A string extension method that encrypts the string.

Syntax

string EncryptRSA(string @this,string key)

Parameters

@this
The @this to act on.
key
The key.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_EncryptRSA
     {
         [TestMethod]
         public void EncryptRSA()
         {
             // Type
             string @this = "Fizz";
 
             // Examples
             string value = @this.EncryptRSA("Buzz"); // return Encrypted string;
 
             // Unit Test
             Assert.AreEqual("Fizz", value.DecryptRSA("Buzz"));
         }
     }
 }
                

String.FormatWith Method

Replaces the format item in a specified String with the text equivalent of the value of a corresponding
Object instance in a specified array.

Syntax

string FormatWith(string @this,object[] values)

Parameters

@this
A String containing zero or more format items.
values
An Object array containing zero or more objects to format.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_FormatWith
     {
         [TestMethod]
         public void FormatWith()
         {
             // Type
             string @this = "{0}{1}";
 
             // Examples
             string value = @this.FormatWith("Fizz", "Buzz"); // return "FizzBuzz";
 
             // Unit Test
             Assert.AreEqual("FizzBuzz", value);
         }
     }
 }
                

String.GetAfter Method

A string extension method that get the string after the specified string.

Syntax

string GetAfter(string @this,string value)

Parameters

@this
The @this to act on.
value
The value to search.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_GetAfter
     {
         [TestMethod]
         public void GetAfter()
         {
             // Type
             string @this = "Fizz";
 
             // Examples
             string value = @this.GetAfter("i"); // return "zz";
 
             // Unit Test
             Assert.AreEqual("zz", value);
         }
     }
 }
                

String.GetBefore Method

A string extension method that get the string before the specified string.

Syntax

string GetBefore(string @this,string value)

Parameters

@this
The @this to act on.
value
The value to search.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_GetBefore
     {
         [TestMethod]
         public void GetBefore()
         {
             // Type
             string @this = "Fizz";
 
             // Examples
             string value = @this.GetBefore("i"); // return "F";
 
             // Unit Test
             Assert.AreEqual("F", value);
         }
     }
 }
                

String.GetBetween Method

A string extension method that get the string between the two specified string.

Syntax

string GetBetween(string @this,string before,string after)

Parameters

@this
The @this to act on.
before
The string before to search.
after
The string after to search.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_GetBetween
     {
         [TestMethod]
         public void GetBetween()
         {
             // Type
             string @this = "Fizz";
 
             // Examples
             string value = @this.GetBetween("F", "z"); // return "i";
 
             // Unit Test
             Assert.AreEqual("i", value);
         }
     }
 }
                

String.HtmlDecode Method

A string extension method that Html decode a string and returns the decoded string..

Syntax

string HtmlDecode(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_HtmlDecode
     {
         [TestMethod]
         public void HtmlDecode()
         {
             // Type
             var @this = "&lt;b&gt;FizzBuzz&lt;/b&gt;";
 
             // Examples
             var value = @this.HtmlDecode(); // return "<b>FizzBuzz</b>";
 
             // Unit Test
             Assert.AreEqual("<b>FizzBuzz</b>", value);
         }
     }
 }
                

String.HtmlEncode Method

A string extension method that Html encode a string and returns the encoded string.

Syntax

string HtmlEncode(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_HtmlEncode
     {
         [TestMethod]
         public void HtmlEncode()
         {
             // Type
             var @this = "<b>FizzBuzz</b>";
 
             // Examples
             var value = @this.HtmlEncode(); // return "&lt;b&gt;FizzBuzz&lt;/b&gt;";
 
             // Unit Test
             Assert.AreEqual("&lt;b&gt;FizzBuzz&lt;/b&gt;", value);
         }
     }
 }
                

String.IsAlpha Method

A string extension method that query if '@this' is Alpha.

Syntax

bool IsAlpha(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_IsAlpha
     {
         [TestMethod]
         public void IsAlpha()
         {
             // Type
             string @thisAlpha = "abc";
             string @thisNotAlpha = "abc123";
 
             // Examples
             bool value1 = @thisAlpha.IsAlpha(); // return true;
             bool value2 = @thisNotAlpha.IsAlpha(); // return false;
 
             // Unit Test
             Assert.IsTrue(value1);
             Assert.IsFalse(value2);
         }
     }
 }
                

String.IsAlphaNumeric Method

A string extension method that query if '@this' is Alphanumeric.

Syntax

bool IsAlphaNumeric(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_IsAlphaNumeric
     {
         [TestMethod]
         public void IsAlphaNumeric()
         {
             // Type
             string @thisAlphaNumeric = "abc123";
             string @thisNotAlphaNumeric = "abc123!<>";
 
             // Examples
             bool value1 = @thisAlphaNumeric.IsAlphaNumeric(); // return true;
             bool value2 = @thisNotAlphaNumeric.IsAlphaNumeric(); // return false;
 
             // Unit Test
             Assert.IsTrue(value1);
             Assert.IsFalse(value2);
         }
     }
 }
                

String.IsLike Method

A string extension method that query if '@this' satisfy the specified pattern.

Syntax

bool IsLike(string @this,string pattern)

Parameters

@this
The @this to act on.
pattern
Specifies the pattern. Use '*' as wildcard string.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_IsLike
     {
         [TestMethod]
         public void IsLike()
         {
             // Type
             string @this = "FizzBuzz3";
 
             // Examples
             bool value1 = @this.IsLike("Fizz*"); // return true;
             bool value2 = @this.IsLike("*zzB*"); // return true;
             bool value3 = @this.IsLike("*Buzz#"); // return true;
             bool value4 = @this.IsLike("*zz?u*"); // return true;
 
             // Unit Test
             Assert.IsTrue(value1);
             Assert.IsTrue(value2);
             Assert.IsTrue(value3);
             Assert.IsTrue(value4);
         }
     }
 }
                

String.IsNotNullOrEmpty Method

A string extension method that queries if '@this' is not (null or empty).

Syntax

bool IsNotNullOrEmpty(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_IsNotNullOrEmpty
     {
         [TestMethod]
         public void IsNotNullOrEmpty()
         {
             // Type
             string @thisValue = "Fizz";
             string @thisNull = null;
 
             // Examples
             bool value1 = @thisValue.IsNotNullOrEmpty(); // return true;
             bool value2 = @thisNull.IsNotNullOrEmpty(); // return false;
 
             // Unit Test
             Assert.IsTrue(value1);
             Assert.IsFalse(value2);
         }
     }
 }
                

String.IsNullOrEmpty Method

A string extension method that queries if '@this' is null or is empty.

Syntax

bool IsNullOrEmpty(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_IsNullOrEmpty
     {
         [TestMethod]
         public void IsNullOrEmpty()
         {
             // Type
             string @thisValue = "Fizz";
             string @thisNull = null;
 
             // Examples
             bool value1 = @thisValue.IsNullOrEmpty(); // return false;
             bool value2 = @thisNull.IsNullOrEmpty(); // return true;
 
             // Unit Test
             Assert.IsFalse(value1);
             Assert.IsTrue(value2);
         }
     }
 }
                

String.Left Method

A string extension method that return the left part of the string.

Syntax

string Left(string @this,int length)

Parameters

@this
The @this to act on.
length
The length.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_Left
     {
         [TestMethod]
         public void Left()
         {
             // Type
             string @this = "Fizz";
 
             // Examples
             string value = @this.Left(2); // return "Fi";
 
             // Unit Test
             Assert.AreEqual("Fi", value);
         }
     }
 }
                

String.NullIfEmpty Method

A string extension method that return null if the value is empty else the value.

Syntax

string NullIfEmpty(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_NullIfEmpty
     {
         [TestMethod]
         public void NullIfEmpty()
         {
             // Type
             string @this = "";
 
             // Examples
             string value = @this.NullIfEmpty(); // return null;
 
             // Unit Test
             Assert.IsNull(value);
         }
     }
 }
                

String.RemoveDiacritics Method

A string extension method that removes the diacritics character from the strings.

Syntax

string RemoveDiacritics(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_RemoveDiacritics
     {
         [TestMethod]
         public void RemoveDiacritics()
         {
             // Type
             string @this = "??????";
 
             // Examples
             string value = @this.RemoveDiacritics(); // return "eeeoia";
 
             // Unit Test
             Assert.AreEqual("eeeoia", value);
         }
     }
 }
                

String.Repeat Method

A string extension method that repeats.

Syntax

string Repeat(string @this,int repeatCount)

Parameters

@this
The @this to act on.
repeatCount
Number of repeats.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_Repeat
     {
         [TestMethod]
         public void Repeat()
         {
             // Type
             string @this = "Fizz";
 
             // Examples
             string value = @this.Repeat(3); // return "FizzFizzFizz";
 
             // Unit Test
             Assert.AreEqual("FizzFizzFizz", value);
         }
     }
 }
                

String.ReplaceEmpty Method

A string extension method that replace all values specified by an empty string.

Syntax

string ReplaceEmpty(string @this,string[] values)

Parameters

@this
The @this to act on.
values
A variable-length parameters list containing values.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_ReplaceEmpty
     {
         [TestMethod]
         public void ReplaceEmpty()
         {
             // Type
             string @this = "FizzBuzz";
 
             // Examples
             string value = @this.ReplaceEmpty("z"); // return "FiBu";
 
             // Unit Test
             Assert.AreEqual("FiBu", value);
         }
     }
 }
                

String.ReplaceEmpty Method

A string extension method that replace all values specified by an empty string.

Syntax

string ReplaceEmpty(string @this,List<string> values)

Parameters

@this
The @this to act on.
values
A variable-length parameters list containing values.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_ReplaceEmpty
     {
         [TestMethod]
         public void ReplaceEmpty()
         {
             // Type
             string @this = "FizzBuzz";
 
             // Examples
             string value = @this.ReplaceEmpty("z"); // return "FiBu";
 
             // Unit Test
             Assert.AreEqual("FiBu", value);
         }
     }
 }
                

String.Reverse Method

A string extension method that reverses the given string.

Syntax

string Reverse(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_Reverse
     {
         [TestMethod]
         public void Reverse()
         {
             // Type
             string @this = "FizzBuzz";
 
             // Examples
             string value = @this.Reverse(); // return "zzuBzziF";
 
             // Unit Test
             Assert.AreEqual("zzuBzziF", value);
         }
     }
 }
                

String.Right Method

A string extension method that return the right part of the string.

Syntax

string Right(string @this,int length)

Parameters

@this
The @this to act on.
length
The length.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_Right
     {
         [TestMethod]
         public void Right()
         {
             // Type
             string @this = "Fizz";
 
             // Examples
             string value = @this.Right(2); // return "zz";
 
             // Unit Test
             Assert.AreEqual("zz", value);
         }
     }
 }
                

String.SaveAs Method

A string extension method that save the string into a file.

Syntax

void SaveAs(string @this,string fileName,bool append)

Parameters

@this
The @this to act on.
fileName
Filename of the file.
append
(Optional) if we should append to the file.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System;
 using System.IO;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_SaveAs
     {
         [TestMethod]
         public void SaveAs()
         {
             var fileInfo = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Examples_System_String_SaveAs.txt"));
             string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Examples_System_String_SaveAs2.txt");
 
             // Type
             string @this = "Fizz";
 
             // Examples
             @this.SaveAs(filePath); // Save string in a file.
             @this.SaveAs(fileInfo); // Save string in a file.
             @this.SaveAs(fileInfo, true); // Append string to existing file.
 
             // Unit Test
             Assert.IsTrue(fileInfo.Exists);
             Assert.IsTrue(new FileInfo(filePath).Exists);
         }
     }
 }
                

String.SaveAs Method

A string extension method that save the string into a file.

Syntax

void SaveAs(string @this,FileInfo file,bool append)

Parameters

@this
The @this to act on.
file
The FileInfo.
append
(Optional) if we should append to the file.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System;
 using System.IO;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_SaveAs
     {
         [TestMethod]
         public void SaveAs()
         {
             var fileInfo = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Examples_System_String_SaveAs.txt"));
             string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Examples_System_String_SaveAs2.txt");
 
             // Type
             string @this = "Fizz";
 
             // Examples
             @this.SaveAs(filePath); // Save string in a file.
             @this.SaveAs(fileInfo); // Save string in a file.
             @this.SaveAs(fileInfo, true); // Append string to existing file.
 
             // Unit Test
             Assert.IsTrue(fileInfo.Exists);
             Assert.IsTrue(new FileInfo(filePath).Exists);
         }
     }
 }
                

String.Split Method

Returns a String array containing the substrings in this string that are delimited by elements of a specified
String array. A parameter specifies whether to return empty array elements.

Syntax

string[] Split(string @this,string separator,StringSplitOptions option)

Parameters

@this
The @this to act on.
separator
A string that delimit the substrings in this string.
option
(Optional) Specify RemoveEmptyEntries to omit empty array elements from the array returned, or None to include
empty array elements in the array returned.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_Split
     {
         [TestMethod]
         public void Split()
         {
             // Type
             string @this = "FizzBuzz";
 
             // Examples
             string[] value = @this.Split("B"); // return new[] {"Fizz", "uzz"}
 
             // Unit Test
             Assert.AreEqual("Fizz", value[0]);
             Assert.AreEqual("uzz", value[1]);
         }
     }
 }
                

String.ToByteArray Method

A string extension method that converts the @this to a byte array.

Syntax

byte[] ToByteArray(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_ToByteArray
     {
         [TestMethod]
         public void ToByteArray()
         {
             // Type
             string @this = "Fizz";
 
             // Examples
             byte[] value = @this.ToByteArray(); // return new byte[] { 70, 105, 122, 122 };
 
             // Unit Test
             Assert.AreEqual(4, value.Length);
         }
     }
 }
                

String.ToDirectoryInfo Method

A string extension method that converts the @this to a directory information.

Syntax

DirectoryInfo ToDirectoryInfo(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System;
 using System.IO;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_ToDirectoryInfo
     {
         [TestMethod]
         public void ToDirectoryInfo()
         {
             // Type
             string @this = AppDomain.CurrentDomain.BaseDirectory;
 
             // Examples
             DirectoryInfo value = @this.ToDirectoryInfo(); // return a DirectoryInfo from the specified path.
 
             // Unit Test
             Assert.AreEqual(@this, value.FullName);
         }
     }
 }
                

String.ToEnum Method

A string extension method that converts the @this to an enum.

Syntax

T ToEnum(string @this)

Parameters

@this
The @this to act on.

Type Parameters

T
Generic type parameter.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_ToEnum
     {
         [TestMethod]
         public void ToEnum()
         {
             // Type
             string @this = "Ordinal";
 
             // Examples
             var value = @this.ToEnum<StringComparison>(); // return StringComparison.Ordinal;
 
             // Unit Test
             Assert.AreEqual(StringComparison.Ordinal, value);
         }
     }
 }
                

String.ToFileInfo Method

A string extension method that converts the @this to a file information.

Syntax

FileInfo ToFileInfo(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System;
 using System.IO;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_ToFileInfo
     {
         [TestMethod]
         public void ToFileInfo()
         {
             // Type
             string @this = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Examples_System_String_ToFileInfo.txt");
 
             // Examples
             FileInfo value = @this.ToFileInfo(); // return a FileInfo for the specified path.
 
             // Unit Test
             Assert.AreEqual(@this, value.FullName);
         }
     }
 }
                

String.ToMemoryStream Method

A string extension method that converts the @this to a MemoryStream.

Syntax

Stream ToMemoryStream(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System.IO;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_ToMemoryStream
     {
         [TestMethod]
         public void ToMemoryStream()
         {
             // Type
             string @this = "FizzBuzz";
 
             // Examples
             using (Stream value = @this.ToMemoryStream()) // return a MemoryStream from the text
             {
                 // Unit Test
                 Assert.IsNotNull(value);
             }
         }
     }
 }
                

String.ToWebRequest Method

A string extension method that converts the @this to a WebRequest.

Syntax

WebRequest ToWebRequest(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System.Net;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_ToWebRequest
     {
         [TestMethod]
         public void ToWebRequest()
         {
             // Type
             string @this = "http://www.zzzportal.com/";
 
             // Examples
             WebRequest value = @this.ToWebRequest(); // return a WebRequest from the specified string.
 
             // Unit Test
             Assert.AreEqual(@this, value.RequestUri.AbsoluteUri);
         }
     }
 }
                

String.ToXDocument Method

A string extension method that converts the @this to a XDocument.

Syntax

XDocument ToXDocument(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System.Xml.Linq;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_ToXDocument
     {
         [TestMethod]
         public void ToXDocument()
         {
             // Type
             string @this = "<Fizz>Buzz</Fizz>";
 
             // Examples
             XDocument value = @this.ToXDocument(); // return a XDocument from the specified string.
 
             // Unit Test
             Assert.AreEqual("<Fizz>Buzz</Fizz>", value.ToString());
         }
     }
 }
                

String.ToXmlDocument Method

A string extension method that converts the @this to an XmlDocument.

Syntax

XmlDocument ToXmlDocument(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using System.Xml;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_ToXmlDocument
     {
         [TestMethod]
         public void ToXmlDocument()
         {
             // Type
             string @this = "<Fizz>Buzz</Fizz>";
 
             // Examples
             XmlDocument value = @this.ToXmlDocument(); // return a XmlDocument from the specified string.
 
             // Unit Test
             Assert.AreEqual("<Fizz>Buzz</Fizz>", value.OuterXml);
         }
     }
 }
                

String.UrlDecode Method

A string extension method that URL decode a string and returns the decoded string..

Syntax

string UrlDecode(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_UrlDecode
     {
         [TestMethod]
         public void UrlDecode()
         {
             // Type
             string @this = "http%3a%2f%2fwww.zzzportal.com%2f%3ftest%3dz";
 
             // Examples
             string value = @this.UrlDecode(); // return "http://www.zzzportal.com/?test=z";
 
             // Unit Test
             Assert.AreEqual("http://www.zzzportal.com/?test=z", value);
         }
     }
 }
                

String.UrlEncode Method

A string extension method that URL encode a string and returns the encoded string.

Syntax

string UrlEncode(string @this)

Parameters

@this
The @this to act on.

Examples


 // Copyright (c) 2013 Jonathan Magnan (http://zzzportal.com)
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here: https://zextensionmethods.codeplex.com/license
 
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 
 namespace ExtensionMethods.Examples
 {
     [TestClass]
     public class System_String_UrlEncode
     {
         [TestMethod]
         public void UrlEncode()
         {
             // Type
             string @this = "http://www.zzzportal.com/?test=z";
 
             // Examples
             string value = @this.UrlEncode(); // return "http%3a%2f%2fwww.zzzportal.com%2f%3ftest%3dz";
 
             // Unit Test
             Assert.AreEqual("http%3a%2f%2fwww.zzzportal.com%2f%3ftest%3dz", value);
         }
     }
 }
                

Last edited Nov 23, 2013 at 7:56 PM by Jonathan_Magnan, version 1