Variable Types
-
Value Type
- bool Boolean
- btye 8-bit unsigned integer 0x00 ~ 0xff
- char 16-bit unsigned integer
- decimal 128 decimal place accuracy value of 10
- double 64位
- float 32 bit
- int 32 bit
- long 64 Wei
- sbyte 8-bit signed
- short 16 Wei
- uint 32-bit unsigned
- ulong 64-bit unsigned
- ushort 16-bit unsigned
sizeof can get a variable number of bits
- Reference types
- Reference type does not contain the value stored in the variable, the type of reference point to a memory location
- Built-in reference types are object dynamic string
- Object Types
- Dynamic type
- You can store any type of value to a variable take effect at runtime
- String type
- String str= “Helloworld“;
- @ Characters plus guidance, you can put string '\' character to look @ "\\ HelloWorld" == "\ HelloWorld"
- String can be any line feeds, spaces and line breaks bonds are considered within the string length
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace StudentCShrap { class MainClassTest { static void Main(string[] args) { String str = "Helloworld\n\n\n"; Console.WriteLine(str.Length);//13 length str = @"12345897522 4152454 524154"; Console.WriteLine(str.Length);//72 length Console.ReadKey(); } } }
- Pointer types
- Another type of memory with the memory address of the C and C ++ pointers have the same effect
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace StudentCShrap { class MainClassTest { static void Main(string[] args) { int* Leng; //错误 CS0214: 指针和固定大小缓冲区只能在不安全的上下文中使用 Console.ReadKey(); } } }
- Another type of memory with the memory address of the C and C ++ pointers have the same effect