-------Windows phone 7 phone development,. NET training, look forward to communicating with you. -------
Knowledge One: The difference between char, varchar, text and nchar, nvarchar, and ntext in SQL
1, CHAR. Char stores fixed-length data conveniently, and the index on the Char field is highly efficient, such as defining char (10), which takes up 10 bytes of space regardless of whether the data you store reaches 10 bytes.
2, VARCHAR. Store variable length data, but storage efficiency is not high char. If the possible value of a field is an unfixed length, we only know that it cannot exceed 10 characters, and it is most cost-effective to define it as VARCHAR (10). The actual length of the varchar type is the actual length of its value +1. Why "+1"? This byte is used to save how much length is actually used.
Consider from the space, use varchar suitable, consider from the efficiency, use char suitable, the key is according to the actual situation to find the tradeoff point.
3, TEXT. Text stores variable-length non-Unicode data with a maximum length of 2^31-1 (2,147,483,647) characters.
4, NCHAR, NVARCHAR, NTEXT. These three kinds of names look more "N" than the previous three. It represents a character that is stored in a Unicode data type. We know the characters, English characters only need one byte of storage is sufficient, but the number of Chinese characters, the need for two bytes of storage, English and Chinese characters at the same time can cause confusion, the Unicode character set is to solve the character set this incompatibility problem, all of its characters are expressed in two bytes, The English character is also expressed in two bytes. The length of nchar and nvarchar is between 1 and 4000. Compared with char and varchar, nchar and nvarchar store up to 4,000 characters, both English and Chinese, while char and varchar can store up to 8,000 English and 4,000 Chinese characters. You can see that the use of nchar, nvarchar data types do not have to worry about the input characters are English or Chinese characters, more convenient, but in the number of storage in English some loss.
So generally, if you have Chinese characters, use Nchar/nvarchar, if you have pure English and numbers, use Char/varchar.
If you are storing articles such as large sections of the time, pure English and numbers, with text, containing Chinese characters, with ntext.
Knowledge Two: A quick and easy way to judge the legality of email
Email.split (' @ ');
The method of email is to judge the string, to determine whether a string is email the fastest (natural inaccurate) method can be split (' @ ') according to the @ splitting, if the split result is 2 parts, that can be roughly judged to be emai address.
Knowledge Three: Placeholders in console applications
Formatting common placeholders
{0} Placeholder in {1} string
Usage: string. Foramt ("{0}{1}", "Dark Horse", "programmer");/get: Dark Horse programmer
"Yyyy-mm-dd HH:mm:ss", "Yyyy/mm/dd HH:mm:ss" ... Date Time formatting
Usage: DateTime.Now.ToString ("Yyyy-mm-dd HH:mm:ss")//Get current time and Format (example): 2009-2-12 13:38:30
". 00" number format, more please refer to the NumberFormatInfo class
Usage: 3.1415926f.tostring (". 00");//Get: 3.14
The format placeholder (%) can be used in conjunction with the following letters to represent specific input and output.
%a,%a reads a floating-point value (only C99 valid)
%c reads a character
%d Read decimal integer
%i read decimal, octal, hexadecimal integer
%o Read into octal integers
%x,%x read into hexadecimal integers
%s reads a string that ends with spaces, tabs, or line breaks
%f,%f,%e,%e,%g,%g is used to enter real numbers, which can be entered in decimal form or exponential form.
%p read a pointer
%u read an unsigned decimal integer
%n the number of equivalent characters for this read value
%[] Scan Character Set combination
%% read% symbol format Input Output example scanf ("%d,%d,%d", &a,&b,&c); Enter three integers from the keyboard, separating scanf ("%c", &s) with commas; Enter a character scanf from the keyboard ("%f", &f); Enter a floating-point type of data from the keyboard printf ("%d\n", a); Output an integer printf ("%f\n", b); Output a floating-point number printf ("%s\n", c); Output a character in which \ n represents a newline
-------Windows phone 7 phone development,. NET training, look forward to communicating with you. -------