Usage of substring in C #

Source: Internet
Author: User
C # contains two overload functions.
Example:Code, Vs2005 compiled through using system;
Using system. Collections. Generic;
Using system. Text; namespace sln_sub
{
Class Program
{
Static void main (string [] ARGs)
{
String mystring = "a quick Fox is jumping over the lazy dog"; // substring () contains two overload functions in C #.
// Example string substring1 = mystring. substring (0); // If the input parameter is a long integer and greater than or equal to 0,
// Start with the long position,
// All the remaining strings are taken after the truncation.
// If the input value is smaller than 0,
// The system throws an argumentoutofrange exception.
// Indicates that the parameter range is out of the bounds string substring2 = mystring. substring (0, 11); // If two long integers are input,
// The first one is the starting position of the original string.
// The last parameter is the length of the substring.
// The exception console. writeline (substring1) occurs if the conditions are not met );
Console. writeline (substring2 );
Console. Readline ();
}
}
}ProgramOutput result: a quick Fox is jumping over the lazy dog
A quick Fox In addition, evaluate the position of character a in string a: A. indexof ('A ').

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.