2.C#字符串的使用

it2025-12-25  6

最后面都有源码的下载地址。

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace _2字符串的使用 { class Program {

static void Main(string[] args) { string email1 = "752422131@qq.com"; string email2 = "284927490@q@q.com"; //找出第一个匹配项所在的索引,索引位置从0开始 int position1 = email2.IndexOf("@"); //获取字符串的长度,从1开始 int position_Length1 = email1.Length; //判断两字符串相等的两种方法 bool LengthIsEquals1 = email1.Length == email2.Length; bool LengthIsEquals1_1 = email1.Length.Equals(email2.Length); //在字符串中截取一段字符串 string QqName = email1.Substring(0, email1.IndexOf("@")); //截取字符串后面所有的字符串 string QqNmaePast = email1.Substring(email1.IndexOf("@"));
最新回复(0)