Converting Convert.ToString (string value)?

Just wondering if there is any reason to use Convert.ToString (string value)

+3


source to share


1 answer


It does nothing, the original string is returned.

See: Convert.ToString (String) Method

Returns the specified string instance; no actual conversion is performed .



This is how it is implemented

public static String ToString(String value) {
    Contract.Ensures(Contract.Result<string>() == value);  // We were always skipping the null check here.
    return value;
}

      

To add one more thing, it System.Convert

has methods to hide each type for itself, like Convert.ToInt32 Method (Int32) and in all cases these methods do nothing, the actual value is returned.

+11


source







All Articles