TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
kobycool68
NA
23
0
global variable in c#
Apr 15 2004 2:15 PM
hey, i need help with c#. i want to define a global variable that all classes know this variable without doing 'new' in every class where i want to use this variable. this is my program - tell me whats wrong or what should i do? (pseudo code) public class AA { private static SqlConnection sqlCon; public AA()//constructor { sqlCon = new SqlConnection(); sqlCon.ConnectionString = "....."; } public SqlConnection con2 { get{return sqlCon;} set{SqlCon = value;} } } } when i try to use sqlCon in other classes there is an error: "Object reference not set to an instance of an object" class BB { AA a; public BB()//constructor { . . . . } void func1() { a.con2.open(); <----------- this is the error line .......... .......... } } thanking you in advance koby
Reply
Answers (
1
)
how to pass a value from a drop down list to a string variable
How to insert string into different column of listView?