当前位置:网站首页>C data type_ From rookie tutorial
C data type_ From rookie tutorial
2022-07-26 22:07:00 【Unity tool man】
data type
Value type (Value types)
Value type variables can be assigned directly to a value . They are from class System.ValueType Derived from .
Value types contain data directly . such as int、char、float, They store numbers separately 、 character 、 Floating point numbers . When you declare a int Type , The system allocates memory to store values .
The following table lists them C# 2010 Value types available in :
| type | describe | Range | Default |
|---|---|---|---|
| bool | Boolean value | True or False | False |
| byte | 8 Bit unsigned integer | 0 To 255 | 0 |
| char | 16 position Unicode character | U +0000 To U +ffff | ‘\0’ |
| decimal | 128 The exact decimal value of ,28-29 Effective digits | (-7.9 x 1028 To 7.9 x 1028) / 100 To 28 | 0.0M |
| double | 64 Bit double precision floating point | (+/-)5.0 x 10-324 To (+/-)1.7 x 10308 | 0.0D |
| float | 32 Bit single precision floating point type | -3.4 x 1038 To + 3.4 x 1038 | 0.0F |
| int | 32 Bit signed integer type | -2,147,483,648 To 2,147,483,647 | 0 |
| long | 64 Bit signed integer type | -9,223,372,036,854,775,808 To 9,223,372,036,854,775,807 | 0L |
| sbyte | 8 Bit signed integer type | -128 To 127 | 0 |
| short | 16 Bit signed integer type | -32,768 To 32,767 | 0 |
| uint | 32 Bit unsigned integer type | 0 To 4,294,967,295 | 0 |
| ulong | 64 Bit unsigned integer type | 0 To 18,446,744,073,709,551,615 | 0 |
| ushort | 16 Bit unsigned integer type | 0 To 65,535 | 0 |
To get the exact size of a type or variable on a specific platform , have access to sizeof Method . expression sizeof(type) Generates a storage size that stores objects or types in bytes . Here's an example to get... On any machine int Storage size of type :
example
using System;
namespace DataTypeApplication
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Size of int: {0}", sizeof(int));
Console.ReadLine();
}
}
}
When the above code is compiled and executed , It will produce the following results :
Size of int: 4
Reference type (Reference types)
object (Object) type
object (Object) type yes C# General type system (Common Type System - CTS) The ultimate base class for all data types in .Object yes System.Object Alias of class . So the object (Object) Type can be assigned to any other type ( Value type 、 Reference type 、 Predefined or user-defined types ) Value . however , Before assigning values , Type conversion is required first .
When a value type is converted to an object type , It's called Packing ; On the other hand , When an object type is converted to a value type , It's called Unpacking .
object obj;
obj = 100; // This is packing
dynamic (Dynamic) type
You can store any type of value in a dynamic data type variable . Type checking of these variables occurs at run time .
Syntax for declaring dynamic types :
dynamic <variable_name> = value;
for example :
dynamic d = 20;
Dynamic types are similar to object types , But type checking of object type variables occurs at compile time , Type checking of dynamically typed variables occurs at run time .
character string (String) type
character string (String) type Allows you to assign any string value to a variable . character string (String) The type is System.String Alias of class . It is from the object (Object) Type derived . character string (String) The value of type can be assigned in two forms : Quotation marks and @ quotes .
for example :
String str = "runoob.com";
One @ Quote string :
@"runoob.com";
C# string The string can be preceded by @( Referred to as " Word for word strings ") The escape character (\) Treat as ordinary characters , such as :
string str = @"C:\Windows";
Equivalent to :
string str = "C:\\Windows";
@ You can wrap any line in the string , Line breaks and indented spaces are calculated within the length of the string .
string str = @"<script type=""text/javascript""> <!-- --> </script>";
User defined reference types include :class、interface or delegate.
Pointer types (Pointer types)
Pointer type variables store another type of memory address .C# Pointer in and C or C++ Pointers in have the same function .
Syntax for declaring pointer types :
type* identifier;
for example :
char* cptr;
int* iptr;
边栏推荐
- Leetcode exercise - Sword finger offer II 005. maximum product of word length
- Actual authority comes from information superiority
- Cmake compiling obs-studio-27.2.0
- 月薪5万的朋友告诉我,你只是在打杂
- JS delay execution window.onload
- Overview of MPLS Basics
- 深入源码剖析String类为什么不可变?(还不明白就来打我)
- Understanding and practice of the trend of Bank of London foreign exchange
- Pytorch 使用RNN模型构建人名分类器
- Thorough load balancing
猜你喜欢

Triangular wave spectrum of MATLAB excitation model

Altium designer 22 Chinese character garbled

我的sql没问题为什么还是这么慢|MySQL加锁规则
![[mysql]substr usage - query the value of specific digits of a field in the table](/img/d5/68658ff15f204dc97abfe7c9e6b354.png)
[mysql]substr usage - query the value of specific digits of a field in the table

2018 arXiv preprint | MolGAN: An implicit generative model for small molecular graphs

Pytoch uses RNN model to build person name classifier

MOS 管示意图

Implementation of MATLAB short-time autocorrelation

现货黄金操作指南与建议(上)

第15章 mysql用户管理
随机推荐
Go -- go language naming specification
NPM, NPM Chinese documents, NPM learning and using
Schematic diagram of MOS tube
Selenium automated test interview questions family bucket
Unity对资源管理器操作 打开资源管理器选择文件并筛选文件
cmake编译obs-studio-27.2.0
LDAP -- realize unified login management of users
08 Du command
吃透负载均衡
Go ---- variable usage in go language
Go----Go 语言中的标识符和关键字
Circular progress bar animation based on cashapelayer and Bezier curve
Altium designer 22 Chinese character garbled
Vb.net chart1 processing
07 DF command
Props with type Object/Array must...
A new technical director asked me to do an IP territorial function~
正规方程法(Normal Equation)原理以及与梯度下降法的区别
matlab 画短时能量图
寻找数字零售的发展新方向,才是保证数字零售可以进入到全新发展阶段的关键