KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I just noticed on string they have a lot of extension methods that I guess I never noticed on strings. Some are like IsEmpty() // Seems to be equivalent to String.IsNullOrEmpty() AsInt() // seems to be equivalent to Convert.ToInt32(string); - does it throw exception as well? I am just wonder do they use the same code under the hook and these are just away to reduce typing or is more going on? Some do seem to be missing though like String.IsNullOrWhiteSpace() Edit Sorry when I said String.IsNullOrWhiteSpace() is missing I ment that there was no extension method. I do have that method is I write what I do above. It also seems that these are not standard in the framework so I am trying to figure out where they came from? I am not sure if resharper added these or if some other reference I have. I don't think I ever imported any extension plugin. When I click definition over IsEmpty() I get this #region Assembly System.Web.WebPages.dll, v4.0.30319 // c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.dll #endregion using System; using System.Runtime.CompilerServices; namespace System.Web.WebPages { // Summary: // Provides utility methods for converting string values to other data types. public static class StringExtensions { // Summary: // Converts a string to a strongly typed value of the specified data type. // // Parameters: // value: // The value to convert. // // Type parameters: // TValue: // The data type to convert to. // // Returns: // The converted value. public static TValue As<TValue>(this string value); // // Summary: // Converts a string to the specified data type and
Tags (comma-separated)
Save Edits
Cancel