Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
Nullable: make Object.ToString() return nullable (dotnet/coreclr#23510)
Browse files Browse the repository at this point in the history
Signed-off-by: dotnet-bot <[email protected]>
  • Loading branch information
safern authored and jkotas committed Apr 10, 2019
1 parent 1e0a366 commit df74dce
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ private static int GetAdvanceHijriDate()
}

int hijriAdvance = 0;
string str = value.ToString();
string? str = value.ToString();
if (string.Compare(str, 0, HijriAdvanceRegKeyEntry, 0, HijriAdvanceRegKeyEntry.Length, StringComparison.OrdinalIgnoreCase) == 0)
{
if (str.Length == HijriAdvanceRegKeyEntry.Length)
if (str!.Length == HijriAdvanceRegKeyEntry.Length)
hijriAdvance = -1;
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/System.Private.CoreLib/shared/System/Object.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Object()

// Returns a String which represents the object instance. The default
// for an object is to return the fully qualified name of the class.
public virtual string ToString()
public virtual string? ToString()
{
return GetType().ToString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,7 @@ private static unsafe void FillStringChecked(string dest, int destPos, string sr
}
}

public static string Concat(object? arg0)
{
if (arg0 == null)
{
return string.Empty;
}
return arg0.ToString();
}
public static string Concat(object? arg0) => arg0?.ToString() ?? string.Empty;

public static string Concat(object? arg0, object? arg1)
{
Expand Down

0 comments on commit df74dce

Please sign in to comment.