Classes in C #

Source: Internet
Author: User

Here we divide the class into three types: String Class (String Class), Math Class (Math Class), DateTime Class (Time Date Class).

When working with classes, note that some symbols appear before the code in the input process (the purple cube represents the method, the function and the black wrench represent the attributes), the Purple Cube's code is followed by parentheses, and the black wrench is not used.

First of all, the string class is the type string (here I use S to represent the string.) )

S.length;

---the length of the output string. Returns an int type, which can be used with convert utility.

S.trimstart ();

This is a function, followed by parentheses. The function is to remove the spaces in front of the string.

S.trimend ();

As above, the function is to remove the space behind the string.

S.trim ();

Remove the front and back spaces of the string.

S.toupper ();

Converts lowercase characters in a string to uppercase, returns a string type

S.tolower ();

becomes a lowercase string

Index/subscript

The order in which the string is recorded in the computer is 0, and if the string has 5 characters, then the corresponding index is 0,1,2,3,4

S.substring (a);

--------used as the intercept string, A is the index/subscript to start intercepting, representing the end of the intercept from index A. Contains the characters corresponding to the subscript

S.substring (A, b);

-------Ibid., A is the index/subscript, and B represents how long to intercept (starting from 1). is to intercept from a until B. Contains the characters corresponding to the subscript

If the time date type is intercepted .... Output with string variable = intercept year-intercept month-intercept day;

The index must be within the length of the string, or it will be an error.

S.indexof ("Put string Inside") starts from 0 of S to find the index position of the first matching character in parentheses, if any, returns the index position without returning-1. Used to find characters. The type of int is returned

S.lastindexof ("string"); -The index of the last occurrence (the rightmost) is the number from the left, starting from the back.

S.startwidth ("The character to be judged");

----Determines whether or not to begin with, returns the bool type.

S.endswidth ("The character to be judged ");

------Determines whether to end with a bool type.

String. Contains ("The character to be judged ");

---------------Determine if a string is included

s.replace ("String to replace", "substituted string");-character substitution returns a string of s.remove (3); -Remove all characters from index to end of string

See Match type again

Math.pow (x, y); -Y-square math.sqrt (x) of the second square x; -Square root Radical X

Math.ceiling (double); -Take the upper limit if the decimal 10.x is placed inside. As long as greater than 10 take one math.floor (double); -Take the lower limit as above, take ten math.round (double); -Take rounded math.abs (double); -Take the absolute value as a positive number.

DateTime type Time Date type

datetime s = new DateTime (XXXX,XX,XX); -Define so that the output s will output the time you entered

s = DateTime.Now; -Get this computer current time output S is the current time

. ToString ("Format"); -Set date format, become string type format=====yyyy-year mm-month dd-day hh-12 hour HH-24 system hour mm-minutes ss-seconds ms-milliseconds

Dt=datetime.now; Set a variable to the current time

Dt. AddYears (); -Increase the number of years DT based on this time. AddMonths (); -Added month dt. AddDays (); -Added Day dt. AddHours (); -Increase the hours dt. AddMinutes (); -Increase the minute dt. AddSeconds (); -Increase the number of seconds in parentheses to increase the write. And if the condition is met, it will be self-motivated.

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

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

. TimeOfDay; -Get the time section. Date; -Get Date part

. Days--the difference is how long. Hours-How many hours in a day is the difference between a day and a few hours, no matter how many days. . Minutes-How many minutes the gap is in a day. Seconds-How many seconds the gap is in a day. Milliseconds-MS

. Total .... Accumulated gap can be calculated all the time difference is not just one day

Classes in C #

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.