Skip to content

Commit e212bea

Browse files
authored
Add IsNullOrEmpty to string (#117)
1 parent 4b5bc6a commit e212bea

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

nanoFramework.CoreLibrary/System/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
[assembly: AssemblyProduct("nanoFramework mscorlib")]
1515
[assembly: AssemblyCopyright("Copyright (c) .NET Foundation and Contributors")]
1616

17-
[assembly: AssemblyNativeVersion("100.5.0.3")]
17+
[assembly: AssemblyNativeVersion("100.5.0.4")]

nanoFramework.CoreLibrary/System/String.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public IEnumerator GetEnumerator()
3737
throw new NotSupportedException();
3838
}
3939

40-
4140
/// <summary>
4241
/// Represents the empty string. This field is read-only.
4342
/// </summary>
4443
public static readonly String Empty = "";
44+
4545
/// <summary>
4646
/// Determines whether this instance and a specified object, which must also be a String object, have the same value.
4747
/// </summary>
@@ -80,9 +80,6 @@ public override bool Equals(object obj)
8080
[MethodImpl(MethodImplOptions.InternalCall)]
8181
public static extern bool operator !=(String a, String b);
8282

83-
84-
85-
8683
/// <summary>
8784
/// Gets the Char object at a specified position in the current String object.
8885
/// </summary>
@@ -814,5 +811,15 @@ public String PadRight(int totalWidth, char paddingChar = ' ')
814811
return this + new String(paddingChar, totalWidth - Length);
815812
}
816813
}
814+
815+
/// <summary>
816+
/// Indicates whether the specified string is <see langword="null"/> or an empty string ("").
817+
/// </summary>
818+
/// <param name="value">The string to test.</param>
819+
/// <returns><see langword="true"/> if the value parameter is <see langword="null"/> or an empty string (""); otherwise, <see langword="false"/>.</returns>
820+
public static bool IsNullOrEmpty(string value)
821+
{
822+
return value == null || value.Length == 0;
823+
}
817824
}
818825
}

0 commit comments

Comments
 (0)