Answers for "c# get variable from another class"

C#
2

c# get variable from another class

// Access variables between different classes 
class ClassA
{
	public static int num = 0;
  	
  	static void Main(string[] args)
    {
    	Console.WriteLine(num);
    }
}

class ClassB
{
	private static int newNum = ClassA.num;
  	
  	public static void Method()
    {
    	Console.WriteLine(newNum);
    }
}
Posted by: Guest on July-18-2021

Code answers related to "c# get variable from another class"

C# Answers by Framework

Browse Popular Code Answers by Language