If a Visual Studio 2010
solution contains two C#
projects where the second projects references the first project:
If a public
static
variable is declared in a class in the first project, should it be visible to a class in the second project?
If a Visual Studio 2010
solution contains two C#
projects where the second projects references the first project:
If a public
static
variable is declared in a class in the first project, should it be visible to a class in the second project?
Yes, and no. It all depends on the access modifier
First off, the second project has to have a reference to the first.
Second, the owning object has to be marked public
and not internal
.
Finally, the field/variable itself has be marked as public
and not internal
/private
/protected
It will be visible if you make it public
. By default it's private
.
Of course, you need a reference to the other project.
Cheers
EDIT: It goes without saying that the class itself must be public
.
public class Class1
{
public static string zaza = "zaza";
}