当前位置:网站首页>String operation methods: replace, delete and split strings
String operation methods: replace, delete and split strings
2022-06-11 02:27:00 【Xia 78】
1、C# Replace string ):
public string Replace(char oldChar,char newChar); Look for... In objects oldChar, If you find , Just use newChar take oldChar Replace .
Such as :
string st = “abcdef”;
string newstring = st.Replace(‘a’, ‘x’);
Console.WriteLine(newstring); // namely :xbcdef
2、Remove(C# Delete string ):
public string Remove(int startIndex); from startIndex Position start , Delete all characters after this position ( Include the characters specified in the current position ).
Such as :
string st = “abcdef”;
string newstring = st.Remove(4);
Console.WriteLine(newstring); // namely :abcd
3、Substring(C# String interception ):
public string Substring(int startIndex); from startIndex Position start , Extract all characters after this position ( Include the characters specified in the current position ).
Such as :
string st = “abcdef”;
string newstring = st.Substring(2);
Console.WriteLine(newstring); // namely :cdef
public string Substring(int startIndex,int count); from startIndex Position start , extract count Characters .
Such as :
string st = “abcdef”;
string newstring = st.Substring(2,2);
Console.WriteLine(newstring); // namely :cd
4、Split(C# Split string )
public string[] Split ( params char[] separator ): according to separator The specified substring without character separation for this instance becomes Unicode A character array , separator It can be an empty array without delimiters or an empty reference .
public string[] Split ( char[] separator, int count ): Parameters count Specifies the maximum number of substrings to return .
Such as :
string st = “ Chinese language and literature | mathematics | English | Physics ”;
string[] split = st.Split(new char[]{’|’},2);
for (int i = 0; i < split.Length; i++)
{
Console.WriteLine(split[i]);
}
边栏推荐
猜你喜欢

Redis learning notes (continuously updating)

In the past 10 years, from zero foundation testing to test architect, he has made himself successful

2022 simulated 100 questions and answers for crane driver (limited to bridge crane) examination

Jetpack Compose Box控件

从测试零基础到测试架构师,这10年,他是这样让自己成才的

To view the data in redis, in addition to the command line and client, you have a third option
![[3.delphi common components] 5 List class component](/img/c0/33b1903c73840b350fea1740eade5e.jpg)
[3.delphi common components] 5 List class component

The annual salary of testers in large factories ranges from 300000 to 8K a month. Roast complained that the salary was too low, but he was ridiculed by netizens?

421. maximum XOR value of two numbers in the array

贵金属白银行情走势图缘何强势?
随机推荐
Orcale driver
[C language] storage of data in memory -1 plastic
[3.delphi common components] 8 dialog box
Colab报错:ImportError: cannot import name ‘_check_savefig_extra_args‘ from ‘matplotlib.backend_bases‘
Secret
378. 有序矩阵中第 K 小的元素
What do you know about the set class? Soul questions from Volume I
421. 数组中两个数的最大异或值
10007. ISBN number
Do tween record
Bingbing learning notes: find the greatest common divisor and the least common multiple. Complex version reverse string
叶酸配体的金属有机骨架材料MOFs负载5-氟尿嘧啶,西达本胺,紫杉醇,阿霉素,柔红霉素,布洛芬,喜树碱,姜黄素,藤黄酸等小分子药物
动态给对象添加属性
如何保障数仓数据质量?
[3.delphi common components] 4 Select class component
About stepping on the pit diary and the association of knowledge points
深度学习基础篇【4】从0开始搭建EasyOCR并进行简单文字识别
STC8A8K64D4 EEPROM读写失败
JS basic part hand exercises
Metal organic framework MOF Al (Diba), MOF Zr (Diba), MOF Fe (Diba) loaded with curcumin / carboxybenzylpenicillin /mtx methotrexate / paclitaxel ptx/ DOX / cisplatin cddp/cpt camptothecin and other d