C#中字符串的逻辑运算符
以下是可以在C#中的字符串上使用的逻辑运算符。
让我们看一个示例,该示例显示如何在字符串上使用逻辑AND运算符-
示例
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class Demo {
public bool CheckUnique(string str) {
string one = "";
string two = "";
for (int i = 0; i < str.Length; i++) {
one = str.Substring(i, 1);
for (int j = 0; j < str.Length; j++) {
two = str.Substring(j, 1);
if ((one == two) && (i != j))
return false;
}
}
return true;
}
static void Main(string[] args) {
Demo d = new Demo();
bool b = d.CheckUnique("amit");
Console.WriteLine(b);
Console.ReadKey();
}
}输出结果
True
热门推荐
10 老婆生日祝福语简短孩子
11 亲戚送行祝福语简短精辟
12 阳历新年祝福语大全 简短
13 讲课祝福语简短10字
14 老师节祝福语的简短
15 生日祝福语男孩 简短独特
16 学生祝福语简短古诗句
17 五二零朋友祝福语大全简短
18 水晶婚夫妻祝福语简短