一、字符串截取問題:
//1.<Case No.> = <Centre Code>/current year/#####, ##### = same no. from <Case Profile No>
Case Profile No:CAP-0001003-2022-00143 Case No.:0001003/2022/00143
entity.crms_case_no = entity.crms_case_profile_no.Remove(0, 4).Replace("-", "/");
二、擴展常用字符串
1. 取字符串的前i個字符
string str1=str.Substring(0,i);
string str1=str.Remove(i,str.Length-i);
2. 去掉字符串的前i個字符
string str1=str.Remove(0,i);
string str1=str.SubString(i);
3.從右邊開始取i個字符:
string str1=str.SubString(str.Length-i);
string str1=str.Remove(0,str.Length-i);
4.從右邊開始去掉i個字符:
string str1=str.Substring(0,str.Length-i);
string str1=str.Remove(str.Length-i,i);
5.如果字符串中有"abc"則替換成"ABC"
str=str.Replace("abc","ABC");
6.c#截取字符串最后一個字符
str1.Substring(str1.LastIndexOf(",")+1);
k = k.Substring(k.Length-1, 1);
三、參考資料
https://www.cnblogs.com/lykbk/archive/2012/06/28/lyk1232132.html
備注:20220209