小编Leo*_*ong的帖子

在字符串数组中找到最短的字符串

我需要提供一个解决方案来查找字符串数组中的最短字符串.我当时认为应该比较每个字符串的长度才能返回.

这是我被困的地方

static void Main(string[] args)
{
    //find the shortest string in an array of string
    string[] names = new string[3]{
        "Tom", "and", "jerry"
    };

    foreach(string name in names){
        Console.Write(name + ", ");
    }

    Console.ReadKey();
}
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮我比较部分并解释它

.net c# arrays string

2
推荐指数
2
解决办法
3464
查看次数

标签 统计

.net ×1

arrays ×1

c# ×1

string ×1