how can i create public variable
-
hi all, how can i create a public variable like string vb="ddd"; i just use vb value any class. how can i do this
sdfsdfsdfs
-
hi all, how can i create a public variable like string vb="ddd"; i just use vb value any class. how can i do this
sdfsdfsdfs
C# doesn't permit global variables. The best you can do is create a class with a static member like this
class YourClass
{
public static string vb = "ddd";
}
...
void YourMethod()
{
string f = YourClass.vb;
}Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
C# doesn't permit global variables. The best you can do is create a class with a static member like this
class YourClass
{
public static string vb = "ddd";
}
...
void YourMethod()
{
string f = YourClass.vb;
}Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
The default accessibility for a class is
internal
, so as long as the class is used within the same assembly, it should work fine. Otherwise, as you said, the class needs to be public.Regards Senthil [MVP - Visual C#] _____________________________ My Blog | My Articles | My Flickr | WinMacro
-
The default accessibility for a class is
internal
, so as long as the class is used within the same assembly, it should work fine. Otherwise, as you said, the class needs to be public.Regards Senthil [MVP - Visual C#] _____________________________ My Blog | My Articles | My Flickr | WinMacro