I have a class defined in a separate file (general.cs).
Where I have 2 declare the instance of this class in order to have a global object
I tried 2 declare it in Program.cs or in form1.cs, but I can't see the object in any other form ...
I have a class defined in a separate file (general.cs).
Where I have 2 declare the instance of this class in order to have a global object
I tried 2 declare it in Program.cs or in form1.cs, but I can't see the object in any other form ...
Global instance of a class
Yonglun Li
As ilyas has suggested, the best thing to do here is to make you class static! so without creating any instance of it every class in your application can call it's fucntions and access its data!
This would be my choice If i would need to do something like you are trying to do!
Think Again for the Right Choice
Best Regards,
R.Tutus
if you need more than one instance of a class then you would need to put it in an array for example, such as a strong typed generic list, then either make that static so you can access it from anywhere, remove or add items, or pass around the collection from one class to another.
ArcPadNewbie
Shyamal Patel
Then First of all dont use static and leave it as its what else to do is make a public class with Dictionary Collection and Key With Unique ID, and Value as That class's Object
Now whever you create an instance of that class put that class's Reference in that Collection in other helping class, Soother classes can use! And you can delete that from that collection whenever needed. Remeber to make safe class to that Objects, See then you have 10 Threades trying to play with the same sgared instance simultainously! So there should be some loginc toprevent them to mess up!
This solution is for you and I hope You understand what I mean!
Need more on that Feel Free to put next question here!
Best Regards,
RyanB88
LOL
!
Yes, As Ilyas Mentioned, You need to make all fields static too!
Best Regards,
dg2007
Lawrex
OMG, tons of problems ....
For the moment I need only one object, so I made the "TableConfiguration" class static.
I can access this class from anywhere, but I can't access any of its fields, even all of them are public .... :-((
TechSupportV