Here is my code which is very simple just for solving the problem. I can't find it myself. I think there is something wrong with my classes.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test
{
public class Time
{
public string Hour { get; set; }
public string Min { get; set; }
}
public class Car
{
public Time Clock { get; set; }
public void CarTime()
{
Clock.Min="3"; // here
}
}
}
Here is my main which calls the cartime function.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test
{
class Program
{
static void Main(string[] args)
{
Car car = new Car();
car.CarTime();
}
}
}
It is not working because I get null reference exception. I don't know why. Sorry for my English.