SubString的用法,及一个相关例子的解释
问题描述:
SubString的用法,及一个相关例子的解释
public static void Main() {
string [] info = {"Name:Felica Walker","Title:Mz.","Age:47","Location:Paris","Gender:F"};
int found = 0;
Console.WriteLine("The initial values in the array are:");
foreach (string s in info)
Console.WriteLine(s);
Console.WriteLine("{0}We want to retrieve only the key information.That is:",Environment.NewLine);
foreach (string s in info) {
found = s.IndexOf(":");
Console.WriteLine(s.Substring(found + 1).Trim());
}
请高手解释下这段代码的意思.还有substring一般是怎么用,用在什么地方啊?
答
substring 一般用于提取字符串的String s="青春无悔无悔青春";String result =s.substring(2,6);substring(int beginindex,int endindex)方法用于提取位置beginindex和位置endindex位置之间的字符串部分.特别要注意...