“This is the 26th day of my participation in the First Challenge 2022. For details: First Challenge 2022.”
Welcome friends to search “Andy Hui” on wechat to pay attention to a wave!
Write some thoughts of the programmer, hope it will help you.
Welcome to become my reader, hope this article can give you some help.
preface
I was so excited to see some of my friends talking about fans as readers in our group today.
Before, I still pay more attention to the amount of reading their articles, whether people forward, how many new attention today. But now, my focus has changed, I no longer care about these external things, I want to write something for the readers, whether the writing is helpful to everyone.
By the way, after the weekend will push two just fan articles, I hope you have the honor to read, you can click in to read, and then quit, thank you for your support.
Today, I’m going to review the basics of C#.
In general, C programs are a set of functions and data types, C++ is a set of functions and classes, and C# programs are a set of type declarations (like JAVA).
So how does this count as a C# program?
- The source code for a C# program or DLL is a set of type declarations
- For executables, there must be a class containing the Main method in the type declaration
- A namespace is a way of grouping and naming related type declarations.
// Namespace namespace WindowsApplication2 {/// <summary> /// </summary> class Test {// Declare and define variables or attributes private int Name { get; set; } private string Age { get; set; }}}Copy the code
type
So what is a 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 object constructed by the template.
A type consists of a name, a data structure used to hold data members, and some behaviors and constraints.
So how do you use types?
This requires instantiating the type, that is, creating the actual object from a type template. In C# programs, each data item is an instance of some type, either native to the language, provided by BCL or other libraries, or customized by the programmer.
storage
Data storage in C# is stored using various types of variables.
Types such as short, int, and long are simple types that can store only one item at a time. The array type stores multiple items of data that are referenced by an index.
However, there are also types that can contain many different types of data items, whose individual data items are called members and have unique names. Includes data members and function members.
Class Test {// Private string Name {get; set; } private int Age { get; set; } private String GetName() {return this.name; }}Copy the code
There are 15 predefined types available in C#, including 13 simple types and 2 non-simple types.
A simple type
11 numeric types, various integer types, floating point types float and double, a high-precision decimal type called decimal. A Unicode character type char, a Boolean type bool.
Numeric types in C# have no Boolean meaning.
Two non-simple types
String is an array of Unicode characters. Object is the base class for all other types.
User-defined types are also possible, and there are six types that can be created by the user.
- Class structure (class)
- Structure type (struct)
- Data Type (array)
- Enumeration Type (enum)
- Delegate Type
- Interface Type
Once a type is declared, objects of that type can be created and used as if they were predefined types.
For any object of a reference type, all its data members are stored in the heap, whether they are of value or reference type.
remarks
Life is short. I don’t want to go for what I can’t see. I want to catch what I can see.
Original is not easy, give a attention.
I am Hui, thank you for reading, if it is helpful to you, please like, forwarding thank you.
I’m glad to make friends with you.