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 (stri
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 23:23:55
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 (stri
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的用法,及一个相关例子的解释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 (stri
substring 一般用于提取字符串的
String s="青春无悔无悔青春";
String result =s.substring(2,6);
substring(int beginindex,int endindex)方法用于提取位置
beginindex和位置endindex位置之间的字符串部分.特别要注意的是,对于开始位置beginindex,Java是基于字符串的首字符位0处理的,但是对于终止位置endindex,Java是基于字符串的首字符位1处理的
提取的结果就是“无悔无悔”