
Substring 用于在 C# 中获取字符串的子部分。为此,我们有 substring() 方法。使用 C# 中的 substring() 方法检查每个子字符串是否有唯一字符。循环它直到字符串的长度。
如果子字符串中的任何一个与另一个子字符串匹配,则意味着该字符串没有唯一字符。
HTShop网上购物系统由恒天网络科技有限公司根据国际先进技术和国内商务特点自主版权开发的一款具有强大功能的B2C电子商务网上购物平台。HTShop以国际上通用流行的B/S(浏览器/服务器)模式进行设计,采用微软公司的ASP.NET(C#)技术构建而成。 2007-11-10 HTShop CS 通用标准版 v1.1.11.10 更新内容自由更换模版功能开放 修改了购买多款商品,会员中心订单只显示
0
您可以尝试运行以下命令确定字符串是否包含所有唯一字符的代码。该示例显示了 Substring() 方法的用法 -
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();
}
}以上就是C# 中的子字符串的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号