using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SomeColors
{
class Program
{
private static int currentCursorX = Console.CursorLeft;
private static int currentCursorY = Console.CursorTop;
static void Main(string[] args)
{
}
}
}
So I can't access my Program
class variables currentCursorX
and currentCursorY
.
Why is that?
You can access private
variables just inside the class they have defined (Program
in your case)!
Make them public
so you can access them from other classes.
public static int currentCursorX = Console.CursorLeft;
public static int currentCursorY = Console.CursorTop;
You should read more about Access Modifiers. Although keep in mind that having public fields in your classes is not a good approach.