Skip to content

Commit

Permalink
Add IsNullOrEmpty to string (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Jan 6, 2021
1 parent 4b5bc6a commit e212bea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nanoFramework.CoreLibrary/System/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
[assembly: AssemblyProduct("nanoFramework mscorlib")]
[assembly: AssemblyCopyright("Copyright (c) .NET Foundation and Contributors")]

[assembly: AssemblyNativeVersion("100.5.0.3")]
[assembly: AssemblyNativeVersion("100.5.0.4")]
15 changes: 11 additions & 4 deletions nanoFramework.CoreLibrary/System/String.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public IEnumerator GetEnumerator()
throw new NotSupportedException();
}


/// <summary>
/// Represents the empty string. This field is read-only.
/// </summary>
public static readonly String Empty = "";

/// <summary>
/// Determines whether this instance and a specified object, which must also be a String object, have the same value.
/// </summary>
Expand Down Expand Up @@ -80,9 +80,6 @@ public override bool Equals(object obj)
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool operator !=(String a, String b);




/// <summary>
/// Gets the Char object at a specified position in the current String object.
/// </summary>
Expand Down Expand Up @@ -814,5 +811,15 @@ public String PadRight(int totalWidth, char paddingChar = ' ')
return this + new String(paddingChar, totalWidth - Length);
}
}

/// <summary>
/// Indicates whether the specified string is <see langword="null"/> or an empty string ("").
/// </summary>
/// <param name="value">The string to test.</param>
/// <returns><see langword="true"/> if the value parameter is <see langword="null"/> or an empty string (""); otherwise, <see langword="false"/>.</returns>
public static bool IsNullOrEmpty(string value)
{
return value == null || value.Length == 0;
}
}
}

0 comments on commit e212bea

Please sign in to comment.