C # String, time, math type

Source: Internet
Author: User

C # in the same as JS in the basic;

Datetime Da=datetime.now; --Get the current time

DateTime da=new datetime (2000,10,10)--Create a new time

Da,tostring ("yyyy MM DD Day")--Set date format yyyy-mm-month dd-Day hh-12 system hour HH-24 system hour mm-minutes ss-seconds ms-milliseconds

Str.toupper && Str.tolower--casing conversion. Unlike JS, there is no case at the back.

Str.trim ();  Str.trimstart ();       Str.trimend (); --Remove the space, go to the front space, go after the space

Str.contains ("a")--judging whether it is contained, type Boolean, bool

Str. Startwidth ("a") str. Endswidth ("a")--judging with what the beginning end usage is the same as contains

Str.replace ("A", "B")--replace the string in the

Math.pow (x, y)--data type double type

------------------------------------------------------------

DateTime TT = new DateTime (2000, 10, 10);
DateTime t = DateTime.Now;
TimeSpan m =tt-t;
int b = m.days;
The use of timespan, the difference in how many days

-----------------------------------------------------------

. AddYears (); -How many years are added on this time basis
. AddMonths (); -Increase Month
. AddDays (); -Increase Day
. AddHours (); -Increase hours
. AddMinutes (); -Add minutes
. AddSeconds (); -Add seconds

. year; -Gets the year of this time variable
. Month; -Get Month
. Day; -Day
. Hour; -Hour
. Minute; -Minute
. Second; -Seconds
. millisecond; -Milliseconds

. DayOfYear; -Gets the current date is the day ordinal of the year
. DayOfWeek; -Get the day of the week

. TimeOfDay; -Get Time section
. Date; -Get Date part

TimeSpan type-time interval type
. Days-the difference in how many day
. Hours-How many hours the gap is in a day
. Minutes-How many minutes the gap in a day
. Seconds-How many seconds difference in a day
. Milliseconds-MS

. Total .... Cumulative gap

C # String, time, math type

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.