Anonymous user
Empty string: Difference between revisions
Edited C# and Visual Basic .NET
(Edited C# and Visual Basic .NET) |
|||
Line 472:
static class Program
{
//
public static void Foo()
{
Line 485:
if (s != null && s.Length == 0) { }
// Check for null or empty (
if (string.IsNullOrEmpty(s)) { }
}
Line 492:
{
// Equality is somewhat convoluted in .NET.
// The
// s is initialized to null. It is a variable of the System.String type that is a null reference and is not
Line 498:
string s = null;
// Alias Console.WriteLine(bool) with a shorter name to make the demonstration code less verbose.
// Assign the empty string literal to s.
Line 2,456:
End If
' Check for null or empty (
If String.IsNullOrEmpty(s) Then
End If</lang>
Line 2,468:
Module Program
Sub Main()
' Equality is somewhat convoluted in .NET, and VB doesn't help by adding legacy means of comparison.
' The
' Some
' do.
Line 2,479 ⟶ 2,478:
Dim s As String = Nothing
' Alias Console.WriteLine(Boolean) with a shorter name to make the demonstration code less verbose.
Dim P
' Assign the empty string literal to s.
Line 2,578 ⟶ 2,577:
Console.WriteLine()
' Each of the
P(s IsNot "")
P(Not Object.ReferenceEquals(s, ""))
|