In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article to share with you is about. NET Framework initialization related implementation skills is how, Xiaobian think quite practical, so share to everyone to learn, I hope you can read this article after harvest, not much to say, follow Xiaobian to see it.
How to correctly apply. NET Framework determines the future programming efficiency of developers. Here we will first understand the operation methods related to initialization of the. NET Framework. If a class has public fields, you can initialize these fields when creating an object instance of the class using the following code:
. NET Framework Implicit Type Variables Related Concepts Detailed Explanation
. NET Framework Open Source Benefits Analysis
. NET Framework Lambda Expression Related Concepts
. NET Framework Timer Object Application Tips Sharing
. NET Framework Type Library Basic Feature List Summary
public class MyClass
{
public String field1;
public int field2;
public bool field3;
}
MyClass my = new MyClass();
my.field1 = "abcd";
my.field2 = 44;
my.field3 = true;
C #3.0 provides a simpler. NET Framework initialization method to initialize these public variables, as follows:
MyClass my = new MyClass { field1 = "abcd", field2 = 44; field3 =true; };
The. NET Framework initialization code above is written somewhat like a constructor with parameters, but instead of calling a constructor with MyClass (because MyClass doesn't have a constructor with three parameters), it's just a magic trick played by the C#compiler. In fact, the above code, after compilation, is still the same as using traditional initialization fields. It just seems simpler grammatically (at least not as many my's). Note that fields initialized using this method must be public (fields that cannot be protected, private, or default modifiers).
C#3.0 also improves how collection classes are initialized (making them initialized like arrays). Unfortunately, this initialization method only supports collection classes that use generics, that is, only collection classes that implement System.Collections.Generic.ICollection can use this initialization method. The code is as follows:
List
< string>myList = new List
< string>{ "data1", "data2", "data3" };
foreach (string data in myList)
{
textBox1.AppendText(data);
}
The above is what the implementation skills related to. NET Framework initialization are. Xiaobian believes that some of the knowledge points may be what we see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
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.