C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » Windows »

Declare global objects in winapplication


Posted Date: 02 Nov 2009      Posted By: sisira kumar sahu      Member Level: Bronze     Points: 1   Responses: 3



Hi All,

i need to declare object in globally in windows application.so i can acess anywhere in my application.please can anyone helpme?

Thank's
Sahu
Appshark.com





Responses

Author: Anuraj    02 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Declare it in the Program.cs, as static members, then you can access it anywhere using Program.Field.

Thanks
Anuraj
THIS POSTING IS PROVIDED "AS IS" WITH NO WARRANTIES, AND CONFERS NO RIGHTS.
BEWARE OF BUGS IN THE ABOVE CODE; I HAVE ONLY PROVED IT CORRECT, NOT TRIED IT.
dotnetthoghts



Author: ABitSmart    02 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Declare it as Public. You can then access it anywhere in your application. If it is declared in a DLL you will need to add reference of the DLL.

Anuraj, How would static make it accessible globally?



Author: Anuraj    03 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

@ABitSmart : Put the static variable in Program.cs, then you can access it globally. As per my understanding the question is about creating a Application variable. If I create a Public variable in anywhere in the application, I need to create the instance of the class to access that variable right? If I create the instance of a class, it will be a fresh copy. Please let me know if I am wrong.

Thanks
Anuraj
THIS POSTING IS PROVIDED "AS IS" WITH NO WARRANTIES, AND CONFERS NO RIGHTS.
BEWARE OF BUGS IN THE ABOVE CODE; I HAVE ONLY PROVED IT CORRECT, NOT TRIED IT.
dotnetthoghts



Post Reply
You must Sign In to post a response.
Next : Connection string for the database
Previous : Crystal reports
Return to Discussion Forum
Post New Message
Category: Windows

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use