/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/fundamentals/runtime-libraries/snippets/System/String/IsNullOrEmpty/csharp/NullString1.cs
40 строк
899 B
Genevieve Warren
Move member remarks (#39270)
30 янв 2024, 00:43
Не верифицирован
30 янв 2024, 00:43
6c88824
Код
Авторство
О чём код?
using System; public class Example { public static void Main() { // <Snippet2> String s = null; Console.WriteLine("The value of the string is '{0}'", s); try { Console.WriteLine("String length is {0}", s.Length); } catch (NullReferenceException e) { Console.WriteLine(e.Message); } // The example displays the following output: // The value of the string is '' // Object reference not set to an instance of an object. // </Snippet2> } } public class Empty { public void Test() { // <Snippet3> String s = ""; Console.WriteLine("The length of '{0}' is {1}.", s, s.Length); // The example displays the following output: // The length of '' is 0. // </Snippet3> } }