.NET/スペースのみの文字列、空の文字列、サイズ0の文字列を判定する
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
#navi(../)
* スペースのみの文字列、空の文字列、サイズ0の文字列を判定...
半角スペースのみの文字列、null(Nothing)な文字列、サイズ0...
Stringクラスには半角スペースのみ、空の文字列、サイズ0の文...
''String.IsNullOrEmpty'', ''String.IsNullOrWhiteSpace'' ...
#contents
* 関連サイト [#q67072ae]
-[[Microsoft .NET | String>https://docs.microsoft.com/ja-...
* 動作確認環境 [#p0dcd7d0]
- Windows 10
- Visual Studio 2019
- .NET Core 3.1
- コンソールアプリケーション
#htmlinsert(windev-top.html)
* C#, Visual Basic サンプルコードと実行結果 [#o97acfe9]
以下に''String.IsNullOrEmpty'', ''String.IsNullOrWhiteSpa...
文字列が条件に成立すれば、true, 不成立であれば false が返...
実際のプログラミングでは、ifにより判定することになります...
** C# [#h5bf8e17]
using System;
class Program
{
static void Main(string[] args)
{
string empty = "";
string nothing = null;
string white_space = @" ";
Console.WriteLine("-- String.IsNullOrEmpty --");
Console.WriteLine("empty: " + String.IsNullOrEmp...
Console.WriteLine("nothing: " + String.IsNullOrE...
Console.WriteLine("white_space: " + String.IsNul...
Console.WriteLine("-- String.IsNullOrWhiteSpace ...
Console.WriteLine("empty: " + String.IsNullOrWhi...
Console.WriteLine("nothing: " + String.IsNullOrW...
Console.WriteLine("white_space: " + String.IsNul...
}
}
** Visual Basic [#y0f0085f]
Imports System
Module Program
Sub Main(args As String())
Dim empty As String = ""
Dim null As String = Nothing
Dim white_space As String = " "
Console.WriteLine("-- String.IsNullOrEmpty --")
Console.WriteLine("empty: " & String.IsNullOrEmp...
Console.WriteLine("nothing: " & String.IsNullOrE...
Console.WriteLine("white_space: " & String.IsNul...
Console.WriteLine("-- String.IsNullOrWhiteSpace ...
Console.WriteLine("empty: " & String.IsNullOrWhi...
Console.WriteLine("nothing: " & String.IsNullOrW...
Console.WriteLine("white_space: " & String.IsNul...
End Sub
End Module
** 実行結果 [#ab821c58]
上記のサンプルコードを実行したときのキャプチャになります。
#ref(01.png)
以上、''String.IsNullOrEmpty'', ''String.IsNullOrWhiteSpa...
空の文字列、サイズが0の文字列、半角スペースのみの文字列を...
終了行:
#navi(../)
* スペースのみの文字列、空の文字列、サイズ0の文字列を判定...
半角スペースのみの文字列、null(Nothing)な文字列、サイズ0...
Stringクラスには半角スペースのみ、空の文字列、サイズ0の文...
''String.IsNullOrEmpty'', ''String.IsNullOrWhiteSpace'' ...
#contents
* 関連サイト [#q67072ae]
-[[Microsoft .NET | String>https://docs.microsoft.com/ja-...
* 動作確認環境 [#p0dcd7d0]
- Windows 10
- Visual Studio 2019
- .NET Core 3.1
- コンソールアプリケーション
#htmlinsert(windev-top.html)
* C#, Visual Basic サンプルコードと実行結果 [#o97acfe9]
以下に''String.IsNullOrEmpty'', ''String.IsNullOrWhiteSpa...
文字列が条件に成立すれば、true, 不成立であれば false が返...
実際のプログラミングでは、ifにより判定することになります...
** C# [#h5bf8e17]
using System;
class Program
{
static void Main(string[] args)
{
string empty = "";
string nothing = null;
string white_space = @" ";
Console.WriteLine("-- String.IsNullOrEmpty --");
Console.WriteLine("empty: " + String.IsNullOrEmp...
Console.WriteLine("nothing: " + String.IsNullOrE...
Console.WriteLine("white_space: " + String.IsNul...
Console.WriteLine("-- String.IsNullOrWhiteSpace ...
Console.WriteLine("empty: " + String.IsNullOrWhi...
Console.WriteLine("nothing: " + String.IsNullOrW...
Console.WriteLine("white_space: " + String.IsNul...
}
}
** Visual Basic [#y0f0085f]
Imports System
Module Program
Sub Main(args As String())
Dim empty As String = ""
Dim null As String = Nothing
Dim white_space As String = " "
Console.WriteLine("-- String.IsNullOrEmpty --")
Console.WriteLine("empty: " & String.IsNullOrEmp...
Console.WriteLine("nothing: " & String.IsNullOrE...
Console.WriteLine("white_space: " & String.IsNul...
Console.WriteLine("-- String.IsNullOrWhiteSpace ...
Console.WriteLine("empty: " & String.IsNullOrWhi...
Console.WriteLine("nothing: " & String.IsNullOrW...
Console.WriteLine("white_space: " & String.IsNul...
End Sub
End Module
** 実行結果 [#ab821c58]
上記のサンプルコードを実行したときのキャプチャになります。
#ref(01.png)
以上、''String.IsNullOrEmpty'', ''String.IsNullOrWhiteSpa...
空の文字列、サイズが0の文字列、半角スペースのみの文字列を...
ページ名: