当前位置:网站首页>Type ~ storage ~ variable in C #
Type ~ storage ~ variable in C #
2022-06-30 18:09:00 【Dotnet cross platform】
Welcome to be my reader , I hope this article can give you some help .
Preface
Today, I saw friends in the group talking about calling fans readers , This makes me very excited .
I used to pay more attention to the amount of articles I read , Has anyone forwarded , How many new concerns are added today . And now , My focus has changed , No longer care about these external things , Think about what you can write to your readers , Does what you write help you .
by the way , In the future, I will push two articles about qiafan over the weekend , I hope all readers have the honor to read , You can click it a little , Just exit again , Thank you for your support .
Review with you today C# The most basic knowledge in .
General situation ,C A program is a set of functions and data types ,C++ Is a set of functions and classes , and C# A program is a set of type declarations (JAVA equally ).
So what kind of writing counts as C# The procedure .
C# Procedure or DLL The source code for is a set of type declarations
For executable programs , A type declaration must contain Main Class of method
A namespace is a way to group and name related type declarations .
// Namespace
namespace WindowsApplication2
{
/// <summary>
/// Representative class
/// </summary>
class Test
{
// Declare and define variables or attributes
private int Name { get; set; }
private string Age { get; set; }
}
}
type
So what is the type ?
Think of a type as a template for creating data structures . The template itself is not a data structure , But it specifies the characteristics of the objects constructed by the template .
Type by name 、 The data structure used to store data members and some behaviors and constraints constitute .
So how to use types ?
This requires instantiation of the type , That is, to create an actual object from a type template . stay C# In the program , Each data item is an instance of some kind , Some of these types come with the language itself , There are plenty of them BCL Or other libraries , It can also be customized by programmers .
Storage
stay C# The data in is stored with various types of variables .
short、int and long Etc. is a simple type , This type of storage can only store one data item at a time . Array (array) Type can store multiple data items , Reference these elements by index .
However, there are other types that can contain many different types of data items , The data item individuals in these types are called members , It has a unique name . Including data members and function members .
class Test
{
// Data member
private string Name { get; set; }
private int Age { get; set; }
// Members of the function
private string GetName()
{
return this.Name;
}
}
stay C# Provided in the 15 There are two predefined types , These include 13 Two simple types and 2 A non simple type .
Simple type
11 Number types , Various integer types , Floating point type float and double, One is called decimal High precision decimal type of . A kind of Unicode Character type char, A boolean type bool.
stay C# The numeric type in does not have a Boolean meaning .
Two non simple types
string, It's a kind of Unicode A character array .object, Is the base class for all other types .


You can also user-defined types , There is a total of 6 The type in can be created by the user .
Class structure (class)
Structure type (struct)
data type (array)
Enumeration type (enum)
Delegate type (delegate)
Interface type (interface)
Once the type is declared , You can create and use this type of object , Just as they are predefined types .
For any object of reference type , All its data members are stored in the heap , Whether they are value types or reference types .
remarks
Life is short , I don't want to pursue what I can't see , I just want to catch what I can see .
Originality is not easy. , Pay attention .
I am a A Hui , Thank you for reading , If it helps you , Please like it 、 forward thank you .
I'm glad to be friends with you .
Previous recommendation
C# Data dictionary in Dictionary
边栏推荐
- Tubes响应性数据系统的设计与原理
- Partition marble (multiple knapsack + binary optimization)
- Communication network electronic billing system based on SSH
- 大文件处理(上传,下载)思考
- Dropout: immediate deactivation
- 腾讯云安装mysql数据库
- Nielseniq welcomes dawn E. Norvell, head of retail lab, to accelerate the expansion of global retail strategy
- 基于SSH的客户关系CRM管理系统
- [Architecture] 1366- how to draw an excellent architecture diagram
- AnimeSR:可学习的降质算子与新的真实世界动漫VSR数据集
猜你喜欢
Design of online shopping mall based on SSH
MIT科技评论2022年35岁以下创新者名单发布,含AlphaFold作者等
Canvas mouse control gravity JS effect
K-line diagram interpretation and practical application skills (see position entry)
If you want to learn software testing, you must see series, 2022 software testing engineer's career development
大文件处理(上传,下载)思考
Redis (V) - advanced data types
Shortcut keys for the rainbow brackets plug-in
Building a basic buildreoot file system
ASP. Net authentication code login
随机推荐
.NET ORM框架HiSql实战-第一章-集成HiSql
Deep understanding of JVM (VI) -- garbage collection (III)
Deep understanding of JVM (III) - memory structure (III)
Inventory in the first half of 2022: summary of major updates and technical points of 20+ mainstream databases
[sword finger offer] 53 - I. find the number I in the sorted array
基于SSH的客户关系CRM管理系统
Redis (VIII) - enterprise level solution (I)
ABAP publish restful service
墨天轮沙龙 | 清华乔嘉林:Apache IoTDB,源于清华,建设开源生态之路
Tencent cloud installs MySQL database
Redis (VII) - sentry
MSF后渗透总结
【剑指Offer】52. 两个链表的第一个公共节点
Importing alicloud ECS locally to solve deployment problems
阿里云ECS导入本地,解决部署的问题
Solve the problem of unable to connect to command metric stream and related problems in the hystrix dashboard
【机器学习】K-means聚类分析
Generate confrontation network, from dcgan to stylegan, pixel2pixel, face generation and image translation.
现在玩期货需要注意什么,在哪里开户比较安全,我第一次接触
News management system based on SSM