TheBulgarianWolf

IntArrayEnteredByUser

Jan 3rd, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.                    
  4. public class Program
  5. {
  6.     public static void Main()
  7.     {
  8.         //the user enters the values as a string devided by spaces or comas
  9.         string input = Console.ReadLine();
  10.         //transfroming the single string input to a string array then to an int array
  11.         int[] arr = input.Split(new char[]{',',' '},StringSplitOptions.RemoveEmptyEntries).Select(x=>int.Parse(x)).ToArray();
  12.        
  13.        
  14.         for(int i =0;i<arr.Length;i++)
  15.         {
  16.             Console.WriteLine(arr[i]);
  17.         }
  18.        
  19.        
  20.     }
  21. }
Add Comment
Please, Sign In to add comment