In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is the local variable of C# implicit type". Interested friends may wish to take a look at it. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "what is the local variable of C# implicit type"!
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# implied type local variable (Local Variable Type Inference)
Var 3.0 introduces the new keyword var, which can be used to replace the original type name when declaring a local variable, that is, when a variable is declared as a var type and no var name type exists in the scope field, then this declaration is called an implied type local variable. As follows (equivalent to / / following the explicit declaration):
Var I = 5 var var j = 23.56 X var k = "C Sharp"; / / string var x bank / error var y = null;// error var z = {1, 2, 3}; / / error
In the debug state, the compiler explains as follows
Key points of C# implied type local variables:
1. Var is the keyword, and the type can be automatically inferred from the following initialization statements. This type is strongly typed.
two。 The initialization statement must be an expression and cannot be empty. And the type can be inferred at compile time. Once initialized, only this type can be stored.
3. Var declares only local variables and cannot be used for fields. It can also be used in statements such as for,foreach,using.
4. Arrays can also be used as implicit types.
5. An initialization statement cannot be an object of its own or a collection initializer, but it can be an new expression that contains an object or initializer.
6. If the local variable declaration contains more than one declarator, its type must be the same.
At this point, I believe that you have a deeper understanding of "what is the local variable of C# implied type". 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.