In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
The main content of this article is to explain "what is the role of C# automatic properties", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "what is the role of C# automatic properties"!
In general, Visual Studio 2008 and .NET 3.5 are based on the .NET 2.0 core, and the .NET 2.0 core itself will not change (if you don't know .NET 2.0, see MSDN or some classic books). The new language features of C # 3.0 have been improved on the basis of .NET 2.0, which can greatly simplify our programming.
The new language features and improvements in C# 3.0 include:
◆ automatic property (Auto-Implemented Properties)
◆ implied type local variable (Local Variable Type Inference)
◆ Anonymous Type (Anonymous Types)
◆ objects and set initializers (Object and Collection Initializers)
◆ extension method (Extension Methods)
◆ Lambda expressions and Lambda expression trees (Lambda Expression and Lambda Expression Trees)
C# automatic attribute (Auto-Implemented Properties)
The C # automatic property avoids the need to manually declare a private member variable and write get/set logic. In VS2008, you can write a class like this, and the compiler automatically generates private variables and default get/set operations. You can also define access levels such as "protected" for get and set respectively.
Under the .net 2.0 framework, we can write a User class like this:
Public class User {private int _ id; private string _ name; private int _ age; public int Id {get {return _ id;} set {_ id = value;}} public string Name {get {return _ name;} set {_ name = value;}} public int Age {get {return _ age;} set {_ age = value;}
Now, it can be simplified as follows:
Public class User {public int Id {get; set;} public string Name {get; set;} public int Age {get; set;}}
With an empty get/set attribute like the one above, it will automatically generate a private member variable for you in the class, and implement a public getter and setter for this variable. We can use the ildasm.exe (IL Code disassembler) tool provided by the .NET development environment to analyze the contents of an assembly or module.
At this point, I believe that you have a deeper understanding of "what is the role of C# automatic properties", you might as well come to the actual operation! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.