Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _3._List_of_Names
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine(); //"Ivan Maria Dimitar Simona Petya"
- List<string> names = input.Split(" ") // масив: ["Ivan", "Maria", "Dimitar", "Simona", "Petya"]
- .ToList(); // лист: {"Ivan", "Maria", "Dimitar", "Simona", "Petya"}
- //обходя всички елементи в списъка names -> отпечатвам + ;
- //1. for - index
- /*for (int index = 0; index <= names.Count - 1; index++)
- {
- Console.WriteLine(names[index] + "; ");
- }*/
- //2. foreach - element
- /*foreach (string name in names)
- {
- Console.Write(name + "; ");
- }*/
- Console.WriteLine(String.Join(';', names));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment