Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我只需要从控制台获取输入行的第一个数字。如果控制台给出的输入是:
20 //this is some input text
然后我需要我的数组只填充数字 20,同时仍然使用 console.readline。
我猜也许你在用 C# 工作???
尝试这个:
var line = "20 //this is some input text"; var num = int.Parse(line.Substring(0, line.IndexOf(' ')));
然后将变量 num 用于您想要的任何内容。你可以把它放在你想要的数组中。