Ii. Data Types

Source: Internet
Author: User
Using system; using system. collections. generic; using system. LINQ; using system. text; namespace _ 2. data type {class program {static void main (string [] ARGs) {// Integer type byte mybyte = 80; ushort myushort = 67; int Myint =-99; ulong myulong = 45679788; console. writeline ("mybyte: {0}", mybyte); console. writeline ("myushort: {0}", myushort); console. writeline ("Myint: {0}", Myint); console. writeline ("myulong: {0} ", Myulong); // floating point type/* because the floating point literal value is double by default, * when assigning values to float and decimal variables, you must add a suffix after. * The suffix f or F must be added to a float variable. * For a variable of the double type, the suffix D or D must be added. * For decimal type variables, the suffix m or m must be added. */Float myfloat = 3.14f; double mydouble = 56.4689; decimal mydecimal = 45487.54679796464 m; console. writeline ("myfloat: {0}", myfloat); console. writeline ("mydouble: {0}", mydouble); console. writeline ("mydecimal: {0}", mydecimal); // character type char mychar = 'a'; console. writeline ("mychar: {0}", mychar); // Boolean bool mybool = true; console. writeline ("mybool: {0}", mybool); // object type object myobject = 100; console. writeline ("myobject type: {0}, value: {1}", myobject. getType (), myobject); // dynamic type Dynamic mydynamic = 'a'; console. writeline ("mydynamic type: {0}, value: {1}", mydynamic. getType (), mydynamic); // string type string mystring = "Hello, world"; console. writeline ("mystring: {0}", mystring); // sizeof method // usage: sizeof (type) console. writeline ("int type occupies {0} bytes", sizeof (INT); console. readkey (); }}/ *** 1. The value type * is derived from the system. valuetype class. * (1) Integer type (default value: 0) * A) signed integer type * sbyte alias system. byte occupies 1 byte * short alias system. int16 occupies 2 bytes * int alias system. int32 occupies 4 bytes * long alias system. int64 occupies 8 bytes * B) the unsigned integer type * byte alias system. sbyte occupies 1 byte * ushort alias system. uint16 occupies 2 bytes * uint alias system. uint32 occupies 4 bytes * ulong alias system. uint64 occupies 8 bytes * (2) floating point type * float alias system. single occupies 4 bytes. The default value is 0.0f * Double alias system. double occupies 8 bytes. The default value is 0.0d * float and double type. +/-M * 2 ^ e The m and E values vary by type. ** The decimal alias system. Decimal occupies 16 bytes. The default value is 0.0 M * the decimal type is expressed in the form of +/-M * 10 ^ e. * (3) character type (unsigned type), which can represent Unicode characters and can store Chinese characters. * Char alias system. char occupies 2 bytes. The default value is '\ 0' * (4) boolean type * bool alias system. boolean boolean values: true and false; default value: false ** 2. Reference Type * (1) object type * object type: C # Common Type System) the ultimate base class of all data types in. * Objects can be assigned values of any other types (value type, reference type, pre-defined type, or user-defined type. * Object type variables are checked during compilation. * (2) dynamic type * dynamic type variables can store values of any type. * Type check is performed for dynamic type variables at runtime. * (3) string type * the string type allows variable allocation of any string without length restrictions. * The string type is the alias of the system. string class. ** 3. pointer type * the pointer type variable stores another type of memory address. * Declare pointer type Syntax: * type * identifier; ** example: * char * cptr; * int * iptr ;**/


This article is from the "MK it life" blog, please be sure to keep this source http://vikxiao.blog.51cto.com/9189404/1585716

Ii. Data Types

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.