SORU
7 AĞUSTOS 2011, Pazar


string.İsNullOrEmpty(dizi) vs. dize.İsNullOrWhiteSpace(dizi)

Bir dize olduğunda kötü uygulama olarak kabul denetlerken string.IsNullOrEmpty(string) string.IsNullOrWhiteSpace(string) bulunur .NET 4.0 ve üzeri?

CEVAP
21 HAZİRAN 2012, PERŞEMBE


Uygulamada söz konusudur

string testString = "";
Console.WriteLine(string.Format("IsNullOrEmpty : {0}", string.IsNullOrEmpty(testString)));
Console.WriteLine(string.Format("IsNullOrWhiteSpace : {0}", string.IsNullOrWhiteSpace(testString)));
Console.ReadKey();

Resutl :
IsNullOrEmpty : True
IsNullOrWhiteSpace : True

************************************************************
string testString = " MDS   ";

IsNullOrEmpty : False
IsNullOrWhiteSpace : False

************************************************************
string testString = "   ";

IsNullOrEmpty : False
IsNullOrWhiteSpace : True

************************************************************
string testString = string.Empty;

IsNullOrEmpty : True
IsNullOrWhiteSpace : True

************************************************************
string testString = null;

IsNullOrEmpty : True
IsNullOrWhiteSpace : True

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • adrianisen

    adrianisen

    25 Kasım 2009
  • Blunty

    Blunty

    13 Mart 2006
  • уσ ρℓz sυв ιℓℓ sυв вαcқ

    уσ ρℓz

    14 EKİM 2010