using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Test();
}
public void Test()
{
string str = "Now is the time for all good men to come to the aid of their party.";
int start;
int at;
Console.WriteLine();
Console.WriteLine("All occurrences of 't' from position 0 to {0}.", str.Length - 1);
//Console.WriteLine("{1}{0}{2}{0}{3}{0}", Environment.NewLine, br1, br2, str);
Console.Write("The letter 't' occurs at position(s): ");
at = 0;
start = 0;
//获取每个t的位置
while ((start < str.Length) && (at > -1))
{
at = str.IndexOf('t', start);
if (at == -1) break;
Console.Write("{0} ", at);
start = at + 1;
}
string a = "a bcde";
int index = a.IndexOf('e');
int index1 = a.IndexOf('e', 0);
//获取带星号的ip
string ip = "127.0.0.123";
string ip2 = "123456";
string index2 = ip2.Substring(0,3);
string changeip = ip.Substring(0,ip.LastIndexOf(".")+1)+"*";
}
}