There is a certain class with a constructor.
public class Neuron { public string name { get; set; } public string rusname { get; set; } public float[,] weight { get; set; } public float sum {get;set;} public Neuron(string name,string rusname) { this.name = name; this.rusname = rusname; weight = new float[7, 7]; sum = 0; } } In another class, I create objects
neurons[0] = new Neuron("Zero", "Ноль"); neurons[1] = new Neuron("One", "Один"); neurons[2] = new Neuron("Two", "Два"); neurons[3] = new Neuron("Three", "Три"); neurons[4] = new Neuron("Four", "Четыре"); neurons[5] = new Neuron("Five", "Пять"); neurons[6] = new Neuron("Six", "Шесть"); neurons[7] = new Neuron("Seven", "Семь"); neurons[8] = new Neuron("Eight", "Восемь"); neurons[9] = new Neuron("Nine","Девять"); At the end of the program, I try to display the object names.
string str = neurons[9].name; string str1 = neurons[9].rusname; In this case, the first line has a value and there are no problems with the output, and the value of the second one is null. For what reason?
Name output method:
public void screen_info() { terminal.Clear(); for(int i = 0; i < neurons.Length; i++) { terminal.Text += neurons[i].name + ": " + neurons[i].sum + Environment.NewLine+Environment.NewLine; } string str = neurons[9].name; string str1 = neurons[9].rusname; terminal.Text += str + " " + str1; } Found a piece of code, after which the value of the second name becomes null
if (File.Exists("weights.txt")) { using(FileStream file = new FileStream("weights.txt", FileMode.Open)) { neurons = (Neuron[]) upload_saves.Deserialize(file); } }