Common methods for C # strings (string)

Source: Internet
Author: User

1. Basic characteristics of strings

The length of the string is not to become;

2. Methods of strings

There are many ways to string strings such as: compare (), Trim (), IsNullOrEmpty (), ToUpper (), and so on.

(1). IsNullOrEmpty ();(It is used to determine whether a string is empty. Returns true if NULL is NOT NULL returns FALSE)

string s = "';

if (string. IsNullOrEmpty (s))

{

}

(2). Format ();(It is used for formatting strings);

Grammar:

String Name= "Zhang San";

String age = "12";

string s = String. Format ("I call {0} this year {1} years old.", Name,age);

(3). Contains ();(It is used to determine whether a string contains another string, if it contains returns True, does not include the return false);

string S1 = "Zhang San pay electricity";

String s2 = "Electricity Bill";

if (S1. Contains (S2))

{

}

Else

{

}

(4). ToUpper ();(The English letter of the specified string into uppercase);

Grammar:

string s = "abc"

s =s.toupper ();

(5). ToLower ();(The English letter of the specified string into lowercase);

Grammar:

string s = "ABC"

s =s.tolower ();

Common methods for C # strings (string)

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.