How can I put three values on the same row separated by space in C #? And then work with them?
Problem: link
How can I put three values on the same row separated by space in C #? And then work with them?
Problem: link
You can use the String.Split to separate into spaces and then convert to decimal array.
using System;
using System.Linq;
namespace Exemplo
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Múltiplos valores em uma linha");
string inp = Console.ReadLine();
decimal [] valores = inp.Split(' ').Select(x=> decimal.Parse(x)).ToArray();//Ou foreach se preferir.
Console.WriteLine(string.Join(", ",valores));
}
}
}