radidim

Reading Array Values from a Single Line (C# Shell App Paste)

Dec 23rd, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
  2. Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
  3. using System;
  4. //using System.IO;
  5. //using System.Linq;
  6. //using System.Collections.Generic;
  7.  
  8. namespace CSharp_Shell
  9. {
  10.  
  11.     public static class Program
  12.     {
  13.         public static void Main()
  14.         {
  15.            string value = "0,5 3,4"; //Console.ReadLine();
  16.            string[] items = value.Split(' ');
  17.            double[] arr = new double[items.Length];
  18.            for(int i = 0;i < items.Length;i++)
  19.            {
  20.                
  21.               arr[i]= double.Parse(items[i]);
  22.               // Console.Write(arr[i]);
  23.                Console.WriteLine(items[i]);
  24.            }
  25.            //Console.WriteLine(items[i]);// грешка  i- не съществува
  26.            
  27.         }
  28.     }
  29. }
Add Comment
Please, Sign In to add comment