【问题标题】:How can I input a string of comma separated numbers, and then reverses its order and displays the reversed array in C#如何输入一串逗号分隔的数字,然后反转其顺序并在 C# 中显示反转后的数组
【发布时间】:2017-09-11 05:46:22
【问题描述】:

我应该在我的代码中使用内置的 explode 和 implode 函数。 例如, 如果输入是 12、56、34、79、26 输出应为 26 79 34 56 12。

这是我的代码enter image description here

【问题讨论】:

    标签: php


    【解决方案1】:

    首先,假设输入为字符串,使用

    String myInput = "12, 56, 34, 79, 26";    
    string[] inputs = str.Split(',');
    Array.Reverse(inputs);
    

    如果您想派生自己的方法,请参阅这个很棒的堆栈溢出分析器here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多