1.索引字符串中的单个字符
string str = “abcd”;
char c = str[0];
2.字符串连接
string s1 = “My age = “;
int myAge = 28;
string cat = s1 + myAge;
3.抽取和定位子串
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”);
4.比较字符串
bool isMatch;
string title = "Ancient Mariner";
isMatch = (title == "ANCIENT AMRINER");
isMatch = (title.ToUpper() == "ANCIENT MARINER");
isMatch = title.Equals("Ancient Mariner");
已有 22658 名学员学习以下课程通过考试
最需教育客户端 软件问题一手掌握
去 App Store 免费下载 iOS 客户端
点击加载更多评论>>