-
定位和抽取子串-C#入门经典教程
资源介绍
字符串操作
抽取和定位子串
string poem = “In Xanadu did Kubla Khan”;
string poemSeg = poem.Substring(10);
poemSeg = poem.Substring(0,9);
int index = poem.IndexOf(“I”);
index = poem.LastIndexOf(“n”);
比较字符串
bool isMatch;
string title = "Ancient Mariner";
isMatch = (title == "ANCIENT AMRINER");
isMatch = (title.ToUpper() == "ANCIENT MARINER");
isMatch = title.Equals("Ancient Mariner");
- 上一篇: 覆盖GetHashCode-C#入门经典教程
- 下一篇: 使用反序列化-C#入门经典教程