开发者

accessing variables from another class

开发者 https://www.devze.com 2023-01-22 11:40 出处:网络
i have 2 classes(a form class and a user-control class) and in the form one i have开发者_开发问答 a list. I would like to access that list from the user control class. How can i do it ? i could pass a

i have 2 classes(a form class and a user-control class) and in the form one i have开发者_开发问答 a list. I would like to access that list from the user control class. How can i do it ? i could pass a reference from the form class to the user control class , but i am curious if there is another way ?

Regards, Alexandru Badescu


Passing it as a reference is your best option - this is how you should do it.

It keeps coupling between the user control and the form to a minimum and allows the user control to be used elsewhere.

0

精彩评论

暂无评论...
验证码 换一张
取 消