你对帮助的理解有误。下面是MSDN的帮助文档,显然和你想象的出入很大。 Reports the index of the first occurrence of the specified String in this instance. The search starts at a specified character position and examines a specified number of character positions.
int SecondSix=sText.IndexOf("6",FirstSix);
string sText="236465"; int lengs=sText.Length; int FirstSix=sText.IndexOf("6",0,lengs); int SecondSix=sText.IndexOf("6",0,lengs);
正如wuye(午夜寻欢) 和Jonly() 所说的: 不过稍微改一下。string sText="236465"; int lengs=sText.Length; int FirstSix=sText.IndexOf("6"); int SecondSix=sText.IndexOf("6",FirstSix+1);
Reports the index of the first occurrence of the specified String in this instance. The search starts at a specified character position and examines a specified number of character positions.
int lengs=sText.Length;
int FirstSix=sText.IndexOf("6",0,lengs);
int SecondSix=sText.IndexOf("6",0,lengs);
不过稍微改一下。string sText="236465";
int lengs=sText.Length;
int FirstSix=sText.IndexOf("6");
int SecondSix=sText.IndexOf("6",FirstSix+1);