How to reference a string from another class?
-
I'm in one class and would like to use a string that was defined in another class. Ho to...
Is the string a static member or instance member? A static member can be referenced without object references like
MessageBox.Show(ClassWithString.MyString);
If it's an instance member, you have to create an instance and then refer to it like
ClassWithString cws = new ClassWithString();
MessageBox.Show(cws.MyString);Of course, I'm assuming that ClassWithString is accessible from your code and that the string is public. HTH. :) Cheers, Vikram.
"When I read in books about a "base class", I figured this was the class that was at the bottom of the inheritence tree. It's the "base", right? Like the base of a pyramid." - Marc Clifton.
-
I'm in one class and would like to use a string that was defined in another class. Ho to...
Here is an article on passing values between forms[^] (Remembering that a Form is just another type of class)
My: Blog | Photos "Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius