Some string operations

Source: Internet
Author: User
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;

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;
// Obtain the location of each t
While (start <str. Length) & (at>-1 ))
{
At = str. IndexOf ('T', start );
If (at =-1) break;
Console. Write ("{0}", );
Start = at + 1;
}

String a = "a bcde ";
Int index = a. IndexOf ('E ');
Int index1 = a. IndexOf ('E', 0 );
// Obtain the ip address with an asterisk
String ip = "127.0.0.123 ";
String ip2 = "123456 ";
String index2 = ip2.Substring (0, 3 );
String changeip = ip. Substring (0, ip. LastIndexOf (".") + 1) + "*";

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.