From cb7b542fb15f613b11aa44fdfb96c6ee5b9a374b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E6=9C=AA=E5=A4=AE?= <102901105+LuckyJie12@users.noreply.github.com> Date: Tue, 10 Jan 2023 21:08:54 +0800 Subject: [PATCH] doc: update cs.md (#266) --- docs/cs.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/cs.md b/docs/cs.md index 79171ac..b518358 100644 --- a/docs/cs.md +++ b/docs/cs.md @@ -213,6 +213,32 @@ string multiLine = """ Console.WriteLine(multiLine); // => Content begin "Hello World!" /\n<>"" end. ``` +###字符串操作 +```cs +//字符串分割 +string Name = "字A符A串A分A割"; +string[] Names=Name.Split(new char[] { 'A' }); +//会以A为媒介把字符串分成若干份 +for (int i = 0; i < Names.Length; i++) +{ + Console.Write(Names[i]); +} +//----------------------------------- +//字符串截取 +string Str = "字符串截取"; +Str = Str.Substring(2, 1); +Console.WriteLine(Str); +//输出结果“串”,意为从第二个下标开始截取一位字符 +//----------------------------------- +//字符串替换 +string Rep = "字符1替换"; +Rep = Rep.Replace("1", "串"); +Console.WriteLine(Rep); +//会把字符中的 “1”替换成“串” +``` + + + 杂项 -----------