using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Example601
{
class Program
{
static void Main(string[] args)
{
string str = "We are the world"; //创建字符串
int firstIndex = str.IndexOf("r"); //获取字符串中“r”第一次出现的位置
int secondIndex = str.IndexOf("r", firstIndex + 1); //获取字符串中“r”第二次出现的位置
int thirdIndex = str.IndexOf("r", secondIndex + 1 ); //获取字符串中“r”第三次出现的位置
//输出三次出现的位置
Console.WriteLine("r第一次出现的位置:" + firstIndex);
Console.WriteLine("r第二次出现的位置:" + secondIndex);
Console.WriteLine("r第三次出现的位置:" + thirdIndex);
Console.ReadLine();
}
}
}