/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/fundamentals/runtime-libraries/snippets/System/String/Overview/csharp/index2.cs
24 строки
727 B
Genevieve Warren
Add remarks for core types (#38970)
05 янв 2024, 22:14
Не верифицирован
05 янв 2024, 22:14
71d1377
Код
Авторство
О чём код?
using System; public class Example11 { public static void Main() { // <Snippet5> string s1 = "This string consists of a single short sentence."; int nWords = 0; s1 = s1.Trim(); foreach (var ch in s1) { if (Char.IsPunctuation(ch) | Char.IsWhiteSpace(ch)) nWords++; } Console.WriteLine("The sentence\n {0}\nhas {1} words.", s1, nWords); // The example displays the following output: // The sentence // This string consists of a single short sentence. // has 8 words. // </Snippet5> } }