「VB.NET」文字列型の静的メソッドを呼び出す

2021年11月29日

書式
1.System.String.Equals(文字列1, 文字列2)
System.Stringクラスのメソッドを呼び出します

2.Public Shared Function Equals (a As String, b As String) As Boolean
指定した 2 つの String オブジェクトの値が同一かどうかを判断します。
パラメーター
a 比較する最初の文字列または null
b 比較する 2 番目の文字列または null。
a の値が b の値と同じ場合は true。それ以外の場合は false。 a と b の両方が null の場合、メソッドは true を返します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Module Module1
Public Sub Main()
Dim strA As String = "study"
Dim strB As String = "study"
' Equalsメソッドを使って2つの文字列が等しいか比べる
Dim res1 As Boolean = String.Equals(strA, strB)
Dim res2 As Boolean = System.String.Equals(strA, strB)
Console.WriteLine("結果1: " + res1.ToString)
Console.WriteLine("結果2: " + res2.ToString)
Console.ReadKey()
End Sub
End Module
Module Module1 Public Sub Main() Dim strA As String = "study" Dim strB As String = "study" ' Equalsメソッドを使って2つの文字列が等しいか比べる Dim res1 As Boolean = String.Equals(strA, strB) Dim res2 As Boolean = System.String.Equals(strA, strB) Console.WriteLine("結果1: " + res1.ToString) Console.WriteLine("結果2: " + res2.ToString) Console.ReadKey() End Sub End Module
Module Module1

    Public Sub Main()

        Dim strA As String = "study"
        Dim strB As String = "study"

        ' Equalsメソッドを使って2つの文字列が等しいか比べる
        Dim res1 As Boolean = String.Equals(strA, strB)
        Dim res2 As Boolean = System.String.Equals(strA, strB)

        Console.WriteLine("結果1: " + res1.ToString)
        Console.WriteLine("結果2: " + res2.ToString)

        Console.ReadKey()
    End Sub

End Module

実行結果
結果1: True
結果2: True

VB.net

Posted by arkgame