Sunday, 15 September 2013

access public variables of a class from another class of an application C#

access public variables of a class from another class of an application C#

I have a public partial class XYZ: Form. I want to use some public data
(lists etc.) of this class in other class(different file) within same
assembly. XYZ is connected to Database, so it has data, whereas the other
class can get data only from class XYZ.
The other class, let say ABC is a COM visible class library, which has 2
interfaces and 2 classes that implement them. ABC is invoked by Perl and
needs data from XYZ.
How should that be done.
When I try
List<a> lst;
XYZ objxyz= new XYZ();
lst= objxyz.lstxyz;
int count= lst.count();
I get count=0; even though lstxyz has some rows. This happens because when
i create an object through 'new' keyword, it doesnt have any data, so
lstxyz count=0.
How can I get data from other class?
Please help me.Thanks a lot.

No comments:

Post a Comment