【问题标题】:What are the best alternatives of this code(written in C#)? [closed]此代码(用 C# 编写)的最佳替代方案是什么? [关闭]
【发布时间】:2022-11-23 22:49:30
【问题描述】:

【问题讨论】:

  • 你有什么选择?代码是否做了它应该做的事情?
  • 请将代码插入为文本, 不像图片!将代码放在带有 3 个反引号的两行之间```
  • 您好,欢迎,提问请参考stackoverflow.com/help/how-to-ask。也不建议发布指向图像或外部代码源的链接。

标签: c# string oop input


【解决方案1】:

使用LinqString.Split 方法是一种可能的解决方案。

string s = "10 4";
int[] mynumbers = s.Split(" ", StringSplitOptions.RemoveEmptyEntries)
.Select(a => Convert.ToInt32(a)).ToArray();

【讨论】:

    猜你喜欢
    • 2020-07-09
    • 2017-06-11
    • 1970-01-01
    • 2021-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-14
    • 1970-01-01
    相关资源
    最近更新 更多