Click here to Skip to main content
16,020,347 members
Home / Discussions / C#
   

C#

 
AnswerRe: Form With Shadow Pin
So Sereyboth29-Mar-11 23:16
So Sereyboth29-Mar-11 23:16 
QuestionI have another problem :( [modified] Pin
Raztor08-Jan-10 16:30
Raztor08-Jan-10 16:30 
AnswerRe: I have another problem :( Pin
Luc Pattyn8-Jan-10 16:50
sitebuilderLuc Pattyn8-Jan-10 16:50 
GeneralRe: I have another problem :( Pin
Raztor08-Jan-10 17:05
Raztor08-Jan-10 17:05 
AnswerRe: I have another problem :( Pin
Abhinav S8-Jan-10 16:55
Abhinav S8-Jan-10 16:55 
GeneralRe: I have another problem :( Pin
Raztor08-Jan-10 17:04
Raztor08-Jan-10 17:04 
GeneralRe: I have another problem :( Pin
Abhinav S8-Jan-10 17:09
Abhinav S8-Jan-10 17:09 
GeneralRe: I have another problem :( Pin
Luc Pattyn8-Jan-10 17:14
sitebuilderLuc Pattyn8-Jan-10 17:14 
Hi,

static members of a class get shared by all instances of that class, so they each get allocated memory only once, and all instances read and write that single instance. A typical example would be a counter to keep track how many instances of some class have been created, or are in existence; such count, by its very nature, does not belong to any such instance, it oversees all instances. That is what static is for.

"solving" a problem by adding static to some variables is very bad practice in general, it does not conform to best practices in object-oriented programming.

In your case, again assuming you had two instances of class2 where you really only wanted one, it is definitely the wrong way to solve the problem. You should:
- not create a second class2 instance;
- instead pass the first instance to interested parties, or better yet pass delegates to execute the operation you want to happen inside class2.

It is my impression you are not really qualified to help your friend; I suggest you buy and study an introductory book on C# before passing advice to others...

Smile | :)

Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

Happy New Year to all.
We hope 2010 soon brings us automatic PRE tags!
Until then, please insert them manually.


GeneralRe: I have another problem :( Pin
Raztor08-Jan-10 17:20
Raztor08-Jan-10 17:20 
GeneralRe: I have another problem :( Pin
DaveyM698-Jan-10 23:20
professionalDaveyM698-Jan-10 23:20 
GeneralRe: I have another problem :( [modified] Pin
Raztor09-Jan-10 4:12
Raztor09-Jan-10 4:12 
GeneralRe: I have another problem :( Pin
DaveyM699-Jan-10 6:23
professionalDaveyM699-Jan-10 6:23 
GeneralRe: I have another problem :( Pin
Raztor09-Jan-10 9:13
Raztor09-Jan-10 9:13 
AnswerRe: I have another problem :( Pin
ajith-k-rajagopalan8-Jan-10 22:00
ajith-k-rajagopalan8-Jan-10 22:00 
Questionopen an av file Pin
saralabasham8-Jan-10 12:16
saralabasham8-Jan-10 12:16 
AnswerRe: open an av file Pin
Bassam Saoud8-Jan-10 12:34
Bassam Saoud8-Jan-10 12:34 
AnswerRe: open an av file Pin
Ravi Bhavnani8-Jan-10 13:41
professionalRavi Bhavnani8-Jan-10 13:41 
AnswerRe: open an avi file Pin
ajith-k-rajagopalan8-Jan-10 21:52
ajith-k-rajagopalan8-Jan-10 21:52 
QuestionSqlDataReader reading beyond end of data Pin
TheJudeDude8-Jan-10 11:58
TheJudeDude8-Jan-10 11:58 
AnswerRe: SqlDataReader reading beyond end of data Pin
Bassam Saoud8-Jan-10 12:31
Bassam Saoud8-Jan-10 12:31 
AnswerRe: SqlDataReader reading beyond end of data Pin
Jimmanuel8-Jan-10 12:33
Jimmanuel8-Jan-10 12:33 
GeneralRe: SqlDataReader reading beyond end of data Pin
TheJudeDude11-Jan-10 5:16
TheJudeDude11-Jan-10 5:16 
GeneralRe: SqlDataReader reading beyond end of data Pin
Jimmanuel11-Jan-10 6:39
Jimmanuel11-Jan-10 6:39 
GeneralRe: SqlDataReader reading beyond end of data Pin
TheJudeDude11-Jan-10 9:04
TheJudeDude11-Jan-10 9:04 
GeneralRe: SqlDataReader reading beyond end of data Pin
Jimmanuel11-Jan-10 9:49
Jimmanuel11-Jan-10 9:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.