In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the grammar optimization method of c #". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what is the method of c # grammar optimization"?
* 1. Entity classes use attributes instead of fields * 1.1 error examples:
* 1.2 correct instance:
In fact, the latter is written in a very simple way, it looks very comfortable, when there are many private fields, the code amount of this class is very ugly.
* 2. The correct use of extension methods
Wrong use: class name. The static method works in the right way: the to-do object calls the static method directly (otherwise, how do you call it an extension method? )
Difference: although both methods can be used normally, the original intention of the design is to extend a class method rather than define a utility class, and once the change space of this class is named correctly, it will not report an error, and the wrong way needs to be modified everywhere.
To correct the second method, you need to introduce the namespace where the extension method is located, and it is recommended that all extension methods be placed in the same folder.
* 3. Delegate * 3.1. What is delegation?
In terms of data structure, a delegate is a user-defined type like a class.
A delegate is an abstraction of a method, which stores the addresses of a series of methods with the same signature and return type. When the delegate is called, all methods contained in the delegate are executed.
* 3.2. Definition of delegation
(characteristics of entrustment: 1. Polymorphism = "delegate class or method 2." Much like the policy pattern in java) delegates are types, as if classes were types. Like classes, delegate types must be declared before they are used to create variables and type objects.
The declaration prototype of the delegate is delegate ()
At this point, I believe you have a deeper understanding of "what is the syntax optimization method of c #". You might as well do it in practice. 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.