Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3948610
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:23:43+00:00 2026-05-20T01:23:43+00:00

I just noticed on string they have a lot of extension methods that I

  • 0

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 specifies a default value.
        //
        // Parameters:
        //   value:
        //     The value to convert.
        //
        //   defaultValue:
        //     The value to return if value is null.
        //
        // Type parameters:
        //   TValue:
        //     The data type to convert to.
        //
        // Returns:
        //     The converted value.
        public static TValue As<TValue>(this string value, TValue defaultValue);
        //
        // Summary:
        //     Converts a string to a Boolean (true/false) value.
        //
        // Parameters:
        //   value:
        //     The value to convert.
        //
        // Returns:
        //     The converted value.
        public static bool AsBool(this string value);
        //
        // Summary:
        //     Converts a string to a Boolean (true/false) value and specifies a default
        //     value.
        //
        // Parameters:
        //   value:
        //     The value to convert.
        //
        //   defaultValue:
        //     The value to return if value is null or an invalid value. The default is
        //     false.
        //
        // Returns:
        //     The converted value.
        public static bool AsBool(this string value, bool defaultValue);
        //
        // Summary:
        //     Converts a string to a System.DateTime value.
        //
        // Parameters:
        //   value:
        //     The value to convert.
        //
        // Returns:
        //     The converted value.
        public static DateTime AsDateTime(this string value);
        //
        // Summary:
        //     Converts a string to a System.DateTime value and specifies a default value.
        //
        // Parameters:
        //   value:
        //     The value to convert.
        //
        //   defaultValue:
        //     The value to return if value is null or an invalid value. The default is
        //     the minimum time value on the system.
        //
        // Returns:
        //     The converted value.
        public static DateTime AsDateTime(this string value, DateTime defaultValue);
        //
        // Summary:
        //     Converts a string to a System.Decimal number.
        //
        // Parameters:
        //   value:
        //     The value to convert.
        //
        // Returns:
        //     The converted value.
        public static decimal AsDecimal(this string value);
        //
        // Summary:
        //     Converts a string to a System.Decimal number and specifies a default value.
        //
        // Parameters:
        //   value:
        //     The value to convert.
        //
        //   defaultValue:
        //     The value to return if value is null or invalid.
        //
        // Returns:
        //     The converted value.
        public static decimal AsDecimal(this string value, decimal defaultValue);
        //
        // Summary:
        //     Converts a string to a System.Single number.
        //
        // Parameters:
        //   value:
        //     The value to convert.
        //
        // Returns:
        //     The converted value.
        public static float AsFloat(this string value);
        //
        // Summary:
        //     Converts a string to a System.Single number and specifies a default value.
        //
        // Parameters:
        //   value:
        //     The value to convert.
        //
        //   defaultValue:
        //     The value to return if value is null.
        //
        // Returns:
        //     The converted value.
        public static float AsFloat(this string value, float defaultValue);
        //
        // Summary:
        //     Converts a string to an integer.
        //
        // Parameters:
        //   value:
        //     The value to convert.
        //
        // Returns:
        //     The converted value.
        public static int AsInt(this string value);
        //
        // Summary:
        //     Converts a string to an integer and specifies a default value.
        //
        // Parameters:
        //   value:
        //     The value to convert.
        //
        //   defaultValue:
        //     The value to return if value is null or is an invalid value.
        //
        // Returns:
        //     The converted value.
        public static int AsInt(this string value, int defaultValue);
        //
        // Summary:
        //     Checks whether a string can be converted to the specified data type.
        //
        // Parameters:
        //   value:
        //     The value to test.
        //
        // Type parameters:
        //   TValue:
        //     The data type to convert to.
        //
        // Returns:
        //     true if value can be converted to the specified type; otherwise, false.
        public static bool Is<TValue>(this string value);
        //
        // Summary:
        //     Checks whether a string can be converted to the Boolean (true/false) type.
        //
        // Parameters:
        //   value:
        //     The string value to test.
        //
        // Returns:
        //     true if value can be converted to the specified type; otherwise, false.
        public static bool IsBool(this string value);
        //
        // Summary:
        //     Checks whether a string can be converted to the System.DateTime type.
        //
        // Parameters:
        //   value:
        //     The string value to test.
        //
        // Returns:
        //     true if value can be converted to the specified type; otherwise, false.
        public static bool IsDateTime(this string value);
        //
        // Summary:
        //     Checks whether a string can be converted to the System.Decimal type.
        //
        // Parameters:
        //   value:
        //     The string value to test.
        //
        // Returns:
        //     true if value can be converted to the specified type; otherwise, false.
        public static bool IsDecimal(this string value);
        //
        // Summary:
        //     Checks whether a string value is null or empty.
        //
        // Parameters:
        //   value:
        //     The string value to test.
        //
        // Returns:
        //     true if value is null or is a zero-length string (""); otherwise, false.
        public static bool IsEmpty(this string value);
        //
        // Summary:
        //     Checks whether a string can be converted to the System.Single type.
        //
        // Parameters:
        //   value:
        //     The string value to test.
        //
        // Returns:
        //     true if value can be converted to the specified type; otherwise, false.
        public static bool IsFloat(this string value);
        //
        // Summary:
        //     Checks whether a string can be converted to an integer.
        //
        // Parameters:
        //   value:
        //     The string value to test.
        //
        // Returns:
        //     true if value can be converted to the specified type; otherwise, false.
        public static bool IsInt(this string value);
    }
}
  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:23:44+00:00Added an answer on May 20, 2026 at 1:23 am

    These aren’t “standard” extension methods – chances are they’ve been added by someone else working on your project. That means we can’t tell what the code’s doing under the hood, but you should be able to find out yourself.

    In Visual Studio you should be able to navigate to the definition of either method – it will either show which assembly the method is in, or go straight to the source code if it can.

    EDIT: Given the comments, it looks like they’re the extension methods from MVC’s StringExtensions class… which violates various bad practices in naming, as far as I can tell – particularly using language specific names within method names instead of the CLR type name. (So AsFloat should be AsSingle for example.) I’d also argue that it should be “To” rather than “As” given that it’s providing a full conversion rather than just returning a view on the original value. Bah humbug ‘n all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just beginning to program in Java and I noticed that String is
I encountered an interesting thing today that I have never noticed before. It appears
I just noticed that moving the mouse cursor across a tooltip does not seem
I just noticed that java.beans.Introspector getBeanInfo does not pickup any superinterface's properties. Example: public
I just noticed that say http://s7.addthis.com/js/250/addthis_widget.js#pub=PUBID does the equivalent of http://s7.addthis.com/js/250/addthis_widget.js?pub=fct-250 but is much
I just noticed that for vector push_back it is push back a reference to
OK, I realize that question might seem weird, but I just noticed something that
Okay, so I've noticed, going through some programs other people have written (for education
I have a file with a module with some routines that take parameters and
I'm just reviewing some of my old code (have some spare time), and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.