C#-এ IsNullOrWhiteSpace() পদ্ধতিটি নির্দেশ করতে ব্যবহৃত হয় যে একটি নির্দিষ্ট স্ট্রিং শূন্য, খালি বা শুধুমাত্র সাদা-স্পেস অক্ষর নিয়ে গঠিত।
সিনট্যাক্স
public static bool IsNullOrWhiteSpace (string val);
উপরে, প্যারামিটার ভ্যাল হল পরীক্ষা করার জন্য স্ট্রিং। আসুন এখন একটি উদাহরণ দেখি −
উদাহরণ
আসুন এখন একটি উদাহরণ দেখি:
using System;
public class Demo {
public static void Main() {
string str1 = null;
string str2 = String.Empty;
Console.WriteLine("Is string1 null or whitespace? = "+String.IsNullOrWhiteSpace(str1));
Console.WriteLine("Is string2 null or whitespace? = "+String.IsNullOrWhiteSpace(str2));
}
} আউটপুট
এটি নিম্নলিখিত আউটপুট তৈরি করবে -
Is string1 null or whitespace? = True Is string2 null or whitespace? = True
উদাহরণ
এখন আরেকটি উদাহরণ দেখা যাক -
using System;
public class Demo {
public static void Main() {
string str1 = "\n";
string str2 = "Tim";
Console.WriteLine("Is string1 null or whitespace? = "+String.IsNullOrWhiteSpace(str1));
Console.WriteLine("Is string2 null or whitespace? = "+String.IsNullOrWhiteSpace(str2));
}
} আউটপুট
Is string1 null or whitespace? = True Is string2 null or whitespace? = False