Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

string.Concat(object) is the only overload returning null if Object.ToString is null #6516

Closed
jamesqo opened this issue Aug 18, 2016 · 1 comment

Comments

@jamesqo
Copy link
Contributor

jamesqo commented Aug 18, 2016

Title basically says it all. All the other Concat/Join overloads in String return string.Empty for null inputs, however this is not the case with Concat(object):

public static String Concat(Object arg0) {
    Contract.Ensures(Contract.Result<String>() != null);
    Contract.EndContractBlock();

    if (arg0 == null)
    {
        return String.Empty;
    }
    return arg0.ToString();
}

If ToString returns null then Concat will return null. This is in contrast to basically all of the other overloads, which return string.Empty for null inputs.

Link to source code

Maybe this should be fixed?

@jamesqo
Copy link
Contributor Author

jamesqo commented Aug 23, 2016

Closing, as the associated PR to fix was closed.

@jamesqo jamesqo closed this as completed Aug 23, 2016
@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant