Some of the experience of some strings of C #

xiaoxiao2021-04-08  293

Some of the experience of some strings of C # [Date: 2004-07-08] [From: ZT]

[Favorite this page]

// get the location code of Chinese characters

Byte [] array = new byte [2];

Array = system.text.Encoding.default.getbytes ("ah");

INT I1 = (SHORT) (Array [0] - '/ 0');

INT I2 = (SHORT) (Array [1] - '/ 0');

// unicode decoding method

Array = system.text.Encoding.uitode.getbytes ("ah");

I1 = (short) (Array [0] - '/ 0');

I2 = (short) (Array [1] - '/ 0');

// unicode anticode is Chinese character

String str = "4a55";

String S1 = Str.Substring (0, 2);

String s2 = str.substring (2, 2);

INT T1 = Convert.TOINT32 (S1, 16);

INT T2 = Convert.TOINT32 (S2, 16);

Array [0] = (Byte) T1;

Array [1] = (Byte) T2;

String s = system.text.Encoding.uitode.getstring (array);

// Default method anti-decoding is Chinese characters

Array [0] = (Byte) 196;

Array [1] = (Byte) 207;

S = system.text.encoding.default.getstring (array);

// Take the string length

S = "IAM square gun";

INT LEN = S.LENGTH; // Will Output AS 6

BYTE [] SARR = system.text.encoding.default.getbytes (s);

Len = Sarr.Length; // Will Output AS 3 3 * 2 = 9

// String plus

System.text.stringbuilder sb = new system.text.stringbuilder ("");

SB.Append ("i");

SB.Append ("am");

Sb.append ("Square Rifle");

String fox;

Fox.tolower () Convert to lowercase letters

Fox.toupper () transform into uppercase letters

Fox.trim () Delete front and rear spaces

Fox.trim (TrimChars) Delete other characters

Fox.trimstart () Delete the front space

Fox.trimend () Delete Space

Fox.padleft (10) increases the left space to make the string to a certain length.

Fox.padright (10) Increases the right space to make the string to a certain length.

Fox.padx (10, '-') adds other characters to make the string to a certain length. X finker: left / right

Fox.split ('') decomposes the string into an array

//format

String sf = string.format ("{0}) {1} {2} Japanese {3} {4} points", TEMP.YEAR, TEMP.MONTH, TEMP.DAY, CURRTIME.TRUANTTIME.HOUR, CURRTIME. TruantTime.minute);

// Some regular expressions

Internet address expression http: // ([/ w-] /.) [/ W-] (/ [/ w- ./?%&=]*)?

EMAIL address expression

/ w ([- .]/w ) *@/w ([-.]/w )**/W ([-.]/w ) *

Zip

/ d {6}

telephone number

(/ (/ D {3} /) | / d {3} -)? / d {8}

// Separate strings

String Total = "AAA, BBB, CCC, DDDD";

String [] stratay;

Char [] charRray = new char [] {','};

Strarray = Total.Split (Chararray);

//date

DateTime T1 = New DateTime (2002, 5, 30);

DateTime T2 = New DateTime (2002, 5, 23);

TIMESPAN DIFF = T1-T2;

Messagebox.show (Diff.days.tostring (DIFF.DAYS.TOSTRIN)

System.datetime.now.tostring ()

DateTime D1 = Convert. TodateTime ("2003-01-01 18:20:01");

String s = D1.toString ("YYYY-MM-DD HH: MM: SS");

//table of Contents

Environment.currentDirectory

Application.Startuppath

After the web form rolls, you can only remember the value of the ASP control, and you can't remember the value of the variable.

转载请注明原文地址:https://www.9cbs.com/read-132838.html

New Post(0)