Did you declare you variable as public? Here is an example (both in the same
namespace):
public class MyClass
{
public int MyIntVar = 0;
public static string MyMsg = "Hello";
}
public class AnotherClass
{
public void AnotherClassMethod()
{
MyClass m = new MyClass();
Console.WriteLine (m.MyIntVar);
Console.WriteLine (MyClass.MyMsg);
}
}
If the variables are public and static then they can be accessed without
instantiating the containing class (MyMsg in the above example).
"Carlos" <cp@swa.com> wrote in message
news:OH**************@TK2MSFTNGP09.phx.gbl...
Ok I do the following
MySpace.MyClass. but I do not see me public variable defined in my public
class ?
"Siva M" <sh******@online.excite.com> wrote in message
news:uV**************@TK2MSFTNGP14.phx.gbl...
Just create a public variable or property (of the desired type) inside a
public class and start using it by qualifying with namspace name (if in a
different namespace) and class name.
"Carlos" <cp@swa.com> wrote in message
news:O5**************@TK2MSFTNGP10.phx.gbl...
Ok,
I am a VB developer but need to do a C# program, my question is how do I
decalre a global variable in c#, in VB.net I juest create a procedure an
declare my Variable as Public myVar and I can use it in all the program
but
how can I do that inc C# ?
Thanks