Как использовать переменную из другого класса в другом файле?
Пишет, что нужна ссылка на объект. При указании ref у переменной выводит ошибку.
using System;
class Program {
int x = Class1.x;
public static int Split( params int[] args) {
if( x != 1 ) {
Console.WriteLine(x / 2);
}
}
static void Main(string[] args) {
int NumberFromScreen = 100;
int ReadLine = Convert.ToInt32(Console.ReadLine());
Console.ReadLine();
string BoolReadLine = Console.ReadLine();
Console.ReadLine();
Console.WriteLine("Загадайте любое число от 1 до 100");
Console.WriteLine("Press 1 to start");
for(int i = 0; i < 6; i++) {
if (ReadLine == 1) {
Console.WriteLine("100");
if (BoolReadLine == "true") {
Console.WriteLine("Спасибо за участие");
} else {
if(x >= 1 && x <= 50) {
Split(50 / 2) ;
} else {
if(x >=50 && x <= 100) {
Split(100 / 2 + 100 / 2);
}
}
}
}
}
}
}
из другого файла:
public class Class1
{
public Class1()
{
int x;
}
}
}