您可以使用Distinct将为您提供不同字符的方法,然后将计数与输入进行比较length,如果它们相等则表示所有字符都不同.
string input = Console.ReadLine();
bool isDifferent = input.Distinct().Count() == input.Length;
Run Code Online (Sandbox Code Playgroud)
注意你需要using System.Linq;使用Distinct方法.
| 归档时间: |
|
| 查看次数: |
68 次 |
| 最近记录: |