title: Cannot transfer value to another class ( c# )
body: <p>I have the first class named:</p>
  
  <pre><code>            Appartments[] appartments;
  </code></pre>
  
  <p>I want to copy the value of "Number" and paste it to "AppartmentInfo.cs" class( I guess they are called Parameters).</p>
  
  <pre><code>        public static void FindFloor(Appartments[] appartments, int amount,out int floorToRound,out AppartmentInfo[] AInfo)
      {
          floorToRound = 0;
          AInfo = new AppartmentInfo[Max];
          for (int i = 0; i &lt; amount; i++)
          {
              AInfo[i].Floor1 = Convert.ToDouble(appartments[i].Number);
              Console.WriteLine(appartments[i].Number);
              if (appartments[i].Number &lt; 27)
              {
                  appartments[i].Number = 1;
              }
              else
              {
  
                  appartments[i].Number /= 27;
              }
          }
      }
  </code></pre>
  
  <p>If there is a need I can post the whole code. I get the error:
  NullReferenceException was unhandled.</p>
  
  <p>Error on the line:</p>
  
  <pre><code>AInfo[i].Floor1 = Convert.ToDouble(appartments[i].Number);
  </code></pre>
  
  <hr>
  
  <p>FULL CODE:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.IO;
  
  namespace P3._1
   {
  class Program
  {
      public const int Max = 20;
      static void Main(string[] args)
      {
          int amount, AmountOfRooms, price, floor, floorToRound;
          Appartments[] appartments;
          AppartmentInfo[] AInfo;
          //AppartmentInfo AInfo = new AppartmentInfo();
          ReadData(out appartments, out amount);
          TextImput(out floor, out AmountOfRooms, out price);
          FindFloor(appartments, amount,out floorToRound,out AInfo);
          Console.ReadKey();
      }
      public static void ReadData(out Appartments[] appartments, out int amount)
      {
          amount = 0;
          appartments = new Appartments[Max];
          using (StreamReader reader = new StreamReader("C:\\Users\\Andrius\\Desktop\\Mokslams\\C#\\Pratybos\\P3\\P3.1 be konstruktoriaus\\Appartments.csv", true))
          {
              reader.ReadLine();
              string line = null;
              while (null != (line = reader.ReadLine()))
              {
                  string[] values = line.Split(',');
                  int number = int.Parse(values[0]);
                  int area = int.Parse(values[1]);
                  int rooms = int.Parse(values[2]);
                  int sellingCost = int.Parse(values[3]);
                  int phone = int.Parse(values[4]);
  
                  Appartments appartmentsObj = new Appartments(number, area, rooms, sellingCost, phone);
                  appartments[amount++] = appartmentsObj;
              }
          }
      }
  
      public static void TextImput(out int floor, out int AmountOfRooms, out int price)
      {
          AmountOfRooms = 0;
          price = 0;
          Console.WriteLine("Iveskite buto aukštą: ");
          floor = int.Parse(Console.ReadLine());
          Console.WriteLine("Iveskite kambariu skaiciu: ");
          AmountOfRooms = int.Parse(Console.ReadLine());
          Console.WriteLine("Maksimali kaina: ");
          price = int.Parse(Console.ReadLine());
  
  
      }
  
      public static void FindFloor(Appartments[] appartments, int amount,out int floorToRound,out AppartmentInfo[] AInfo)
      {
          floorToRound = 0;
          AInfo = new AppartmentInfo[Max];
          for (int i = 0; i &lt; amount; i++)
          {
              AInfo[i].Floor1 = Convert.ToDouble(appartments[i].Number);
              Console.WriteLine(appartments[i].Number);
              if (appartments[i].Number &lt; 27)
              {
                  appartments[i].Number = 1;
              }
              else
              {
  
                  appartments[i].Number /= 27;
              }
          }
      }
  
  
  
  
  }
  </code></pre>
  
  <p>}</p>