Lewis

Lewis

  • NA
  • 10
  • 0

arrays in classes

Oct 5 2010 3:44 PM

Hi,
My first trys at using an array of classes; I get a null reference exception. A very simple test program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ArrayInClass
{
     summary
     Interaction logic for MainWindow.xaml
     summary
    public partial class MainWindow  Window
    {
        public class tmHgt
        {
            public string time;         time
            public string hgt;          height
        }
        public class T_RefOut
        {
            public int mo;              month
            public int day;             day
            public tmHgt[] tmh = new tmHgt[5];
        };
        public T_RefOut[] TRefOuts;
        public MainWindow()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            TRefOuts = new T_RefOut[28];
            for (int i1 = 0; i1  28; i1++)
            {
                TRefOuts[i1].mo = 0;
                TRefOuts[i1].day = 0;
                for (int i2 = 0; i2  5; i2++)
                {
                    TRefOuts[i1].tmh[i2].time = ;
                    TRefOuts[i1].tmh[i2].hgt = ;
                }
            }
        }
    }
}

Would appreciate any help. Thanks.  -Lew 

Answers (2)