小编Cra*_*van的帖子

比较C#中的字符串长度

我需要制作确定两个更长的单词输入的功能.我曾尝试使用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();
    }
}
Run Code Online (Sandbox Code Playgroud)

c# string string-length

-1
推荐指数
1
解决办法
3101
查看次数

标签 统计

c# ×1

string ×1

string-length ×1