C # code Char, DateTime, escape character, pre-defined reference

Source: Internet
Author: User

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;

Namespace ConsoleApplication3
{
Class Program
{
static void Main (string[] args)
{
The following is Char
Char ch1 = ', ';
Console.WriteLine (Char.isseparator (CH1));
char CH2 = ';
Console.WriteLine (Char.iswhitespace (CH2));
Console.WriteLine (Ch1.compareto (' a '));
String str1;
STR1 = Char.convertfromutf32 (CH1);
Console.WriteLine (STR1);
Console.WriteLine (Char.equals (CH1, CH2));
Console.WriteLine (CH1. GetTypeCode ());
char CH3 = ' \a ';
Console.WriteLine (Char.iscontrol (CH3));
Console.WriteLine ();

The following are datetime
DateTime DT1 = new DateTime (2018, 01, 04, 11, 20, 00);
DateTime DT2 = new DateTime (2018, 07, 04, 14, 20, 00);
Console.WriteLine (DT1. date);//output current time accurate to date, not involving a few seconds
Console.WriteLine (DT1. DayOfWeek);//Output The current time is the first day of the week
Console.WriteLine (DT1. DayOfYear);//Output The current time is the first day of the year
Console.WriteLine (DT1. Hour);//Output the current time in pips
Console.WriteLine (System.DateTime.Now);//output current time, accurate to seconds
Console.WriteLine (System.DateTime.DaysInMonth (1998,2));//outputs how many days of the month are in the specified year
Console.WriteLine (DateTime.Now.Add (New TimeSpan (1008601, 0, 0)))//output specified time interval, time interval format is seconds
Console.WriteLine (DateTime.Parse ("2018/01/04 11:20:00"));//output is converted from a string to a time
Console.WriteLine (DT1. Tolongdatestring () + "" +dt1. Tolongtimestring ());//output DT1 time, accurate to the second
Console.WriteLine (DT1. ToShortDateString () + "" + dt1. Toshorttimestring ());//output DT1 time, accurate to minute
TimeSpan ts1 = dt1-dt2;//Set a time interval and output
Console.WriteLine (TS1);
Console.WriteLine (System.DateTime.Now + ts1);//output current time plus a specific time interval to get the time
Console.WriteLine (Ts1. Days+ "" +ts1. Hours+ "" +ts1. Totaldays);//interval take all day, the number of hours to 24 to take, in days units
Console.WriteLine ();

The following is an escape character
Console.WriteLine ("Iowa's" level "+" "+" Missouri "number" + "+" mk7\\406 mm naval gun ");
Console.WriteLine ("\ ' hello\ '");
Console.WriteLine ("' Hello '");
Console.WriteLine (@ "' Hello '");
Console.WriteLine ();

The following are reference types
String str2 = "Queen Elizabeth class battleship";
string str3 = str2;
Console.WriteLine ("STR2:" +str2+ "" + "STR3:" +STR3);
STR2 = "Scharnhorst class battleship";
Console.WriteLine ("STR2:" + str2 + "+" STR3: "+ STR3);

Console.read ();
}
}
}

C # code Char, DateTime, escape character, pre-defined reference

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.