C# 文字列の文字数がゼロであることを判定する
C#で、IsNullOrEmptyを使用して、文字列の文字数がゼロであることを判定するサンプルコードを記述してます。
環境
- OS windows10 pro 64bit
- Microsoft Visual Studio Community 2019 Version 16.7.1
IsNullOrEmpty使い方
IsNullOrEmptyを使用すると、文字列の文字数がゼロであることを判定することが可能です。
using System;
using System.Collections.Generic;
namespace testapp
{
class Program
{
static void Main(string[] args)
{
string str1 = "mebee";
string str2 = "";
Console.WriteLine(String.IsNullOrEmpty(str1));
// False
Console.WriteLine(String.IsNullOrEmpty(str2));
// True
}
}
}
-
前の記事
javascript ontouchendでタッチ終了のイベントを取得する 2021.01.06
-
次の記事
javascript 枠線を追加する 2021.01.07
コメントを書く