using System;
public class Example
{
public static void Main()
{
string str1 = "apple";
string str2 = "banana";
// Compare two strings using CompareTo method
int result = str1.CompareTo(str2);
if (result < 0)
{
Console.WriteLine($"{str1} is less than {str2}.");
}
else if (result == 0)
{
Console.WriteLine($"{str1} is equal to {str2}.");
}
else
{
Console.WriteLine($"{str1} is greater than {str2}.");
}
}
}
CompareTo 方法用于比较两个字符串。下一篇:c# 字符串比较
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站