Class and application of 9.c#

Source: Internet
Author: User
Tags square root

1.int i=x.length;//length (Gets the length of the string, returning a value of type int)

2.x=x.trim ();(remove space before and after the string)

TrimStart ();(Remove the preceding space)

TrimEnd ();(remove the trailing space)

3.x = X.toupper ();(convert lowercase English characters in a string to uppercase)

X=x.tolower ();(convert uppercase English characters in a string to lowercase)

4.string p=x.substring (6,8)//substring (m,n) intercepts a string from bit m, intercepts N

Replace ("", "")//replaces all strings that match the string condition of the specified segment.

5.Math class

Double A = 3.14;
A = Math.ceiling (a);//Fetch online
A = Math.floor (a);//Remove Line

A = Math.Round (a);
Rounded
It was an odd time, and it was. 5 Fetch online
At that time even, and was. 5 Remove the line

A = A * Math.pi;//pi is pi

A = Math.sqrt (a);//square root

6.

Date Time Class
Before you use it, you need to initialize it to new.
Just give him the system. When the current time is not available, new
DateTime dt = new DateTime ();
DT = DateTime.Now;
Get years, months, days, hours, minutes, seconds
int year = dt. year;
int month = dt. Month;
int day = dt. Day;
From the hour down are double types
Double hour = dt. Hour;
Double minute = dt. Minute;
Double second = dt. Second;


DayOfWeek dd = dt. DayOfWeek;
Take a few weeks

Placeholder
yyyy .... Years
Mm.... Month
Dd.... Day
HH .... When
Mm.... Score of
Ss.... Seconds
string s = dt. ToString ("yyyy mm month DD Day hh" mm minutes ss seconds ");
In the original time add how many years, months, days, hours, minutes, seconds
DT = dt. AddDays ();
DT = dt. AddHours ();
DT = dt. AddMinutes ();
DT = dt. AddYears ();

Example one: Enter the ID number to intercept the date of birth.

Example two: Please enter the mailbox, 1. There is only one @;2. Cannot begin with @; [email protected] after at least one.; [email protected] and. cannot be together; 5. cannot be ended with.

Example three: Please enter the time of the beginning of love, calculate how many days of love now.

Example four: Randomly generate a four-digit verification code and then validate against the input

Class and application of 9.c#

Related Article

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.