Advertisement
Legiomax

C#_3_split_string

Jan 28th, 2024 (edited)
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | Software | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace C_Ijun
  9. {
  10.     internal class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             char separator = ' ';
  15.            
  16.             string text = "Дана строка с текстом, используя метод строки String.Split() получить массив слов, которые разделены пробелом в тексте и вывести массив, каждое слово с новой строки.";
  17.             Console.WriteLine($"Изначальная строка: {text}");
  18.  
  19.             string[] arrayText = text.Split(separator);
  20.  
  21.             foreach (var subText in arrayText)
  22.             {
  23.                 Console.WriteLine($"Слово: {subText}");
  24.             }
  25.  
  26.             Console.ReadKey();
  27.         }
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement