Click here to Skip to main content
16,008,299 members
Home / Discussions / C#
   

C#

 
AnswerRe: How can I remotely explore my LAN? Remoting? Pin
#realJSOP4-Jun-10 7:31
professional#realJSOP4-Jun-10 7:31 
AnswerRe: How can I remotely explore my LAN? Remoting? Pin
Member 18349914-Jun-10 8:52
Member 18349914-Jun-10 8:52 
GeneralRe: How can I remotely explore my LAN? Remoting? Pin
#realJSOP5-Jun-10 1:56
professional#realJSOP5-Jun-10 1:56 
Questionproblem in Class Pin
SajjadZare4-Jun-10 6:15
SajjadZare4-Jun-10 6:15 
AnswerRe: problem in Class Pin
Abhinav S4-Jun-10 6:18
Abhinav S4-Jun-10 6:18 
GeneralRe: problem in Class Pin
SajjadZare4-Jun-10 6:51
SajjadZare4-Jun-10 6:51 
GeneralRe: problem in Class Pin
Luc Pattyn4-Jun-10 8:37
sitebuilderLuc Pattyn4-Jun-10 8:37 
GeneralRe: problem in Class Pin
OriginalGriff4-Jun-10 8:50
mveOriginalGriff4-Jun-10 8:50 
Because what you are doing is creating two separate instances, you can only do this if there is a single variable "a" that is common to all instances of "class1". You do this with the static keyword.:
class class1
   {
   public static int a;
   }
You can then use it in any instance.
form1:
class1 s=new class1();
class1.a=10

form2:
class1 c = new class1();
MessageBox.Show(class1.a.ToString());
But you can't use "s.a" or "c.a" because it would look confusing - you might think that "a" was specific to the particular instance of class1 rather than shared between them.

It's a bit like cars: They can all have a colour, but they don't share it: YourCar has a different colour (blue) to MyCar (red). They do share common information: NumberOfWheels (4)

So you can't say "What colour is a car?" but you can say "How many wheels has a car?"
You can say "What colour is my car?" or "What colour is your car?" because this specifies exactly which car you are talking about.

If you feel you must access "a" via an instance, you can declare a property which does that for you (but it isn't really recommended):
class class1
   {
   private static int a;
   public int A
      {
      get { return a; }
      set { a = value;}
      }
   }
You can now access "A" via "s.A" and "c.A" to get the same value which is shared between all instances of class1.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.

GeneralRe: problem in Class Pin
Luc Pattyn4-Jun-10 9:30
sitebuilderLuc Pattyn4-Jun-10 9:30 
GeneralRe: problem in Class Pin
OriginalGriff4-Jun-10 9:41
mveOriginalGriff4-Jun-10 9:41 
GeneralRe: problem in Class [modified] Pin
Luc Pattyn4-Jun-10 9:49
sitebuilderLuc Pattyn4-Jun-10 9:49 
GeneralRe: problem in Class Pin
OriginalGriff4-Jun-10 11:53
mveOriginalGriff4-Jun-10 11:53 
GeneralRe: problem in Class Pin
Luc Pattyn4-Jun-10 11:57
sitebuilderLuc Pattyn4-Jun-10 11:57 
AnswerRe: problem in Class Pin
Not Active4-Jun-10 6:57
mentorNot Active4-Jun-10 6:57 
QuestionEnterprise Library Logging Application Block: using special sources Pin
Shtel4-Jun-10 3:16
Shtel4-Jun-10 3:16 
QuestionFinding base class of an object Pin
dashingsidds4-Jun-10 3:07
dashingsidds4-Jun-10 3:07 
AnswerRe: Finding base class of an object Pin
JoeSharp4-Jun-10 3:27
JoeSharp4-Jun-10 3:27 
AnswerRe: Finding base class of an object Pin
Anthony Mushrow4-Jun-10 3:45
professionalAnthony Mushrow4-Jun-10 3:45 
GeneralRe: Finding base class of an object Pin
dashingsidds4-Jun-10 4:25
dashingsidds4-Jun-10 4:25 
AnswerRe: Finding base class of an object Pin
#realJSOP4-Jun-10 4:52
professional#realJSOP4-Jun-10 4:52 
QuestionIssue with Environment.SpecialFolder.MyDocuments Pin
False Chicken4-Jun-10 2:09
False Chicken4-Jun-10 2:09 
AnswerRe: Issue with Environment.SpecialFolder.MyDocuments Pin
Johnny J.4-Jun-10 2:16
professionalJohnny J.4-Jun-10 2:16 
GeneralRe: Issue with Environment.SpecialFolder.MyDocuments Pin
False Chicken4-Jun-10 2:22
False Chicken4-Jun-10 2:22 
GeneralRe: Issue with Environment.SpecialFolder.MyDocuments Pin
Johnny J.4-Jun-10 2:23
professionalJohnny J.4-Jun-10 2:23 
Questioncolor get changed in another pc Pin
eraser9504-Jun-10 2:03
eraser9504-Jun-10 2:03 

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.