Class 7.25

Source: Internet
Author: User
Tags square root time and date

7.25//string class String s = "ABCDEFGB"; int a = s.length; get length Console.WriteLine (s.length);

Remove the front and back Space Console.Write (S.trim ()); Only remove the front space Console.Write (S.trimstart ()); Console.WriteLine (123); Only remove the trailing space Console.Write (S.trimend ());

Converts all lowercase letters to uppercase Console.WriteLine (S.toupper ()) to lowercase Console.WriteLine (S.tolower ());

Returns the index number of the first occurrence of the character or string Note: The index number is 0-based and returns a value of-1. Indicates that the character or string Console.WriteLine (S.indexof ("abc") was not found;

Returns the index number of the last occurrence of the character or string Console.WriteLine (S.lastindexof ("B"));

Substring intercepts a string to write an argument, it means to intercept from this index number, until the last Console.WriteLine (S.substring (3));

Two parameters indicate, from which position to start interception, intercept how long Console.WriteLine (S.substring (4, 4));

StartsWith whether to start with a * * string Console.WriteLine (S.startswith ("AB"));

Whether the endswith ends with a * * string Console.WriteLine (S.endswith ("B"));

Whether the contains contains Console.WriteLine (S.contains ("CD"));

Replace replaces Console.WriteLine (S.replace ("B", "BB")); Console.WriteLine (s); Console.ReadLine ();

Please enter your ID number to intercept your birthday 370321199003053330 console.write ("Please enter your ID number:");

String cid = Console.ReadLine ();

String year = CID. Substring (6, 4);

String month = CID. Substring (10, 2);

String day = cid. Substring (12, 2);

Console.WriteLine ("Your Date of birth is: {0} years {1} months {2} days. ", year, month, day); Console.ReadLine ();

Exercise: Determine if the mailbox format is correct 1. There is only one @

2. Cannot start with @

There is at least one after [email protected].

[email protected] and. Can't stay together.

5. Cannot end with.

Enter two time and date to calculate how many days difference (totaldays)

Console.Write ("Please enter the first time date (****/**/** * * *:* *:* *):");

DateTime dt1 = DateTime.Parse (Console.ReadLine ());

Console.Write ("Please enter a second time date (****/**/** * * *:* *:* *):");

DateTime DT2 = DateTime.Parse (Console.ReadLine ()); Console.WriteLine ((DT2-DT1). Totaldays);

Math Classes for Math class

Ceiling Ceiling Access Console.WriteLine (math.ceiling (4.4)); Floor Flooring Remove Line Console.WriteLine (Math.floor (4.4));

Open square root Console.WriteLine (MATH.SQRT (4));

piπ3.141592 Console.WriteLine (Math.PI);

Round rounding//odd. 5 When the acquisition is on-line//even. 5 of the time obtained is the Downline Console.WriteLine (Math.Round (4.5)); Console.ReadLine (); DateTime date type should be initialized before use

DateTime dt = new DateTime ();

Gets the current time DateTime dt = DateTime.Now;

Console.WriteLine (DT); Console.WriteLine (dt. Month); Get year dt. Year gets the month dt. Month gets the day dt. Day gets the hour dt. Hour gets the sub dt. Minute gets the second dt. Second gets the day of the week DayOfWeek d = dt. DayOfWeek; Console.WriteLine (d); String Dow =d.tostring (); Switch (DOW) {case "Monday": Console.WriteLine ("Monday"), break, Case "Tuesday": Console.WriteLine ("Tuesday");

Class 7.25

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.