/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/core/deploying/snippets/deploy-with-vs/csharp/deployment-example.cs
35 строк
1 KB
Genevieve Warren
First set of nullable fixes (csharp, core, fundamentals) (#35123)
26 апр 2023, 20:01
Не верифицирован
26 апр 2023, 20:01
bce1d95
Код
Авторство
О чём код?
using System; using System.Text.RegularExpressions; namespace Applications.ConsoleApps { public class ConsoleParser { public static void Main() { Console.WriteLine("Enter any text, followed by <Enter>:\n"); String? s = Console.ReadLine(); ShowWords(s ?? "You didn't enter anything."); Console.Write("\nPress any key to continue... "); Console.ReadKey(); } private static void ShowWords(String s) { String pattern = @"\w+"; var matches = Regex.Matches(s, pattern); if (matches.Count == 0) { Console.WriteLine("\nNo words were identified in your input."); } else { Console.WriteLine($"\nThere are {matches.Count} words in your string:"); for (int ctr = 0; ctr < matches.Count; ctr++) { Console.WriteLine($" #{ctr,2}: '{matches[ctr].Value}' at position {matches[ctr].Index}"); } } } } }