You can use the
using Directive (C# Reference)[
^]
First you need a class, that defines the variable either as static as a regular member.
Let's say
namespace App
{
public class MyClass
{
public MyClass()
{
myVariable = 1;
}
public int myVariable;
public static int StaticVariable = 3;
}
}
using App;
MyClass myClass = new MyClass();
var v = myClass.myVariable;
var stat = MyClass.StaticVariable;
or you can use the full identifier
App.MyClass myClass = new App.MyClass();
var v = myClass.myVariable;
var stat = App.MyClass.StaticVariable;
Then if you should access a variable directly from outside the scope of the class is another matter entirely.