Свойство поля не работает - C#
Формулировка задачи:
using System.IO;
using System;
public class myClass
{
private int[] t_1000 = new int[0];
public int[] arenda_up
{
get
{
return t_1000;
}
set
{
t_1000 = new int[value.Length];
for (int i = 0; i < value.Length; i++)
{
t_1000[i] = value[i] * 1000;
}
}
}
public myClass()
{
arenda_up = new int[5];
}
}
public class Pole
{
public static myClass[] kletki;
}
class Program
{
static void Main()
{
Pole.kletki = new myClass[28];
for (int i = 0; i < 28; i++)
{
Pole.kletki[i] = new myClass();
}
Pole.kletki[1].arenda_up[0] = 1;
Pole.kletki[1].arenda_up[1] = 2;
Console.WriteLine(Pole.kletki[1].arenda_up[0]);
Console.WriteLine(Pole.kletki[1].arenda_up[1]);
}
}Решение задачи: «Свойство поля не работает»
textual
Листинг программы
static void Main(string[] args)
{
Pole.kletki = new myClass[28];
for (int i = 0; i < 28; i++)
{
Pole.kletki[i] = new myClass();
}
int[] arr = new int[5] { 1, 2, 0, 0, 0 };
Pole.kletki[1].arenda_up = arr;
//Pole.kletki[1].arenda_up[0] = 1;
//Pole.kletki[1].arenda_up[1] = 2;
Console.WriteLine(Pole.kletki[1].arenda_up[0]);
Console.WriteLine(Pole.kletki[1].arenda_up[1]);
Console.Read();
}