CSHARPPROGLIB Telegram 6325
⚙️ Проверка на пустоту

Когда нужно проверить строку на пустоту в C# есть два популярных метода:

string.IsNullOrEmpty(str) возвращает true, если строка равна null или имеет длину 0 ("").

string.IsNullOrWhiteSpace(str) идёт дальше: он также учитывает пробелы, табы и переводы строк. То есть " " будет считаться пустой.

Код:
Console.WriteLine(string.IsNullOrEmpty("   ")); // False
Console.WriteLine(string.IsNullOrWhiteSpace(" ")); // True


Если нужно проверить только на null и пустую строку — используйте IsNullOrEmpty. Если важно исключить строки, состоящие только из пробелов или невидимых символов — выбирайте IsNullOrWhiteSpace.

🐸 Библиотека шарписта

#sharp_view
Please open Telegram to view this post
VIEW IN TELEGRAM
🥱28👍62😁2🥰1



tgoop.com/csharpproglib/6325
Create:
Last Update:

⚙️ Проверка на пустоту

Когда нужно проверить строку на пустоту в C# есть два популярных метода:

string.IsNullOrEmpty(str) возвращает true, если строка равна null или имеет длину 0 ("").

string.IsNullOrWhiteSpace(str) идёт дальше: он также учитывает пробелы, табы и переводы строк. То есть " " будет считаться пустой.

Код:

Console.WriteLine(string.IsNullOrEmpty("   ")); // False
Console.WriteLine(string.IsNullOrWhiteSpace(" ")); // True


Если нужно проверить только на null и пустую строку — используйте IsNullOrEmpty. Если важно исключить строки, состоящие только из пробелов или невидимых символов — выбирайте IsNullOrWhiteSpace.

🐸 Библиотека шарписта

#sharp_view

BY Библиотека шарписта | C#, F#, .NET, ASP.NET




Share with your friend now:
tgoop.com/csharpproglib/6325

View MORE
Open in Telegram


Telegram News

Date: |

According to media reports, the privacy watchdog was considering “blacklisting” some online platforms that have repeatedly posted doxxing information, with sources saying most messages were shared on Telegram. Private channels are only accessible to subscribers and don’t appear in public searches. To join a private channel, you need to receive a link from the owner (administrator). A private channel is an excellent solution for companies and teams. You can also use this type of channel to write down personal notes, reflections, etc. By the way, you can make your private channel public at any moment. Don’t publish new content at nighttime. Since not all users disable notifications for the night, you risk inadvertently disturbing them. In handing down the sentence yesterday, deputy judge Peter Hui Shiu-keung of the district court said that even if Ng did not post the messages, he cannot shirk responsibility as the owner and administrator of such a big group for allowing these messages that incite illegal behaviors to exist. Each account can create up to 10 public channels
from us


Telegram Библиотека шарписта | C#, F#, .NET, ASP.NET
FROM American