Easily master data interactions between Windows Forms in. NET (iii)
Zhzuo (Autumn Maple)
In the first and second articles we implemented data interaction using constructors, attributes, and methods with parameters, followed by the use of static classes to complete data interaction between forms. This is also a kind of data interaction method that we often use.
Three Using static Classes
The following is a defined class:
Using System;
Using System.Collections;
Namespace ZZ
{
public class Appdatas
{
private static ArrayList Listdata;
Static Appdatas ()
{
Listdata = new ArrayList ();
Listdata.add ("dotnet");
Listdata.add ("C #");
Listdata.add ("asp.net");
Listdata.add ("WebService");
Listdata.add ("XML");
}
public static ArrayList Listdata
{
Get{return Listdata;}
}
public static ArrayList Getlistdata ()
{
return listdata;
}
}
}
It contains a static class member, Listdata, and a static constructor (Appdatas) to initialize the Listdata data. There is also a static property Listdata and a static Getlistdata () method, they achieve the same function is to return to Listdata.
Since the previous two articles have been talked about a lot, here is not to elaborate, the following is the complete code:
In summary, I think the more static analogy is to load the application's configuration file into a static class, let all forms and other instances use this data through static properties as well as static methods, such as a three-tier structure or a multi-tier structure that can be accessed instead of being passed across multiple instances. Here we are talking about Windows Forms, and in fact interacting data between two different instances can be implemented in the scenario of three articles, unless it is a specific attribute or method of this class. Now all finished, although not what advanced things, but hope to some beginners to help, if can really solve some of the practical problems of friends, but also I did not waste time to write articles, but also welcome friends to carry out technical exchanges, and jointly improve, My email address is zhzuocn@163.com.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.