Cra*_*van -1 c# string string-length
我需要制作确定两个更长的单词输入的功能.我曾尝试使用if语句String.Length,但我无法正确使用它.制作这个功能的最佳方法是什么?以下是主程序.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class LongerWord
{
    public static void Main(string[] args) 
    {
        Console.Write("Give 1. word >");
        String word1 = Console.ReadLine();
        Console.Write("Give 2. word >");
        String word2 = Console.ReadLine();
        String longer = LongerString(word1, word2);
        Console.WriteLine("\"" + longer + "\" is longer word");
        Console.ReadKey();
    }
}
这应该是......的一个开始......
private string LongerString(string x, string y)
{
    return x.Length > y.Length ? x : y;
}
| 归档时间: | 
 | 
| 查看次数: | 3101 次 | 
| 最近记录: |