Paulo Morgado

.NET Development & Architecture

This Blog

Syndication

Search

Tags

News

Unit Test Today! Get Typemock Isolator!

Projects

Books

 

Visitors

Visitor Locations

Community

Email Notifications

Archives

Profile

Disclaimer

The opinions and viewpoints expressed in this site are mine and do not necessarily reflect those of Microsoft, my employer or any community that I belong to. Any code or opinions are offered as is. Products or services mentioned are purchased by me, made available to me by my employer or the manufacturer/vendor which doesn't influence my opinion in any way.

Extension methods missing from System.String in the .NET Framework 3.5 (Beta 1)

UPDATE: Extension methods

Extension methods are a feature of the new C# language specification (also available in Visual Basic [^] [^]):

This new feature should be used in existing classes like the String class by making the folowing methods extension methods:

public static int Compare(this string strA, string strB);

public static int Compare(this string strA, string strB, bool ignoreCase);

public static int Compare(this string strA, string strB, System.StringComparison comparisonType);

public static int Compare(this string strA, string strB, bool ignoreCase, System.Globalization.CultureInfo culture);

public static int Compare(this string strA, int indexA, string strB, int indexB, int length);

public static int Compare(this string strA, int indexA, string strB, int indexB, int length, bool ignoreCase);

public static int Compare(this string strA, int indexA, string strB, int indexB, int length, System.StringComparison comparisonType);

public static int Compare(this string strA, int indexA, string strB, int indexB, int length, bool ignoreCase, System.Globalization.CultureInfo culture);

public static int CompareOrdinal(this string strA, string strB);

public static int CompareOrdinal(this string strA, int indexA, string strB, int indexB, int length);

public static string Concat(this string str0, string str1);

public static string Concat(this string str0, string str1, string str2);

public static string Concat(this string str0, string str1, string str2, string str3);

public static string Copy(this string str);

public static string Intern(this string str);

public static string IsInterned(this string str);

public static bool IsNullOrEmpty(this string value);

This would allow us to write code like this:

if (someString.IsNullOrEmpty())

{

    //...

}

If you would like to see this in the next release of the .NET framework, vote on this suggestion.

Published Sun, May 13 2007 19:41 by Paulo Morgado

Comments

# UPDATE: Extension methods@ Monday, May 14, 2007 6:32 PM

Looks like I was way wrong in here and here . I had thought that from the top of my head because I tried

Paulo Morgado

Leave a Comment

(required) 
(required) 
(optional)
(required) 
If you can't read this number refresh your screen
Enter the numbers above: