So I’m on the Constructors and Inheritance lecture in C# Intermediate and when I push “Start” on the program, the Console will appear for a second then the program automatically terminates itself. Yet there are no errors. Why is this happening? Is it a bug in my program?
Here’s my code:
Program.cs
namespace Constructors
{
class Program
{
static void Main(string[] args)
{
var car = new Car();
}
}
}
Vehicle.cs
using System;
namespace Constructors
{
public class Vehicle
{
public Vehicle()
{
Console.WriteLine(“Vehicle is being initialized.”);
}
}
}
Car.cs
using System;
namespace Constructors
{
public class Car : Vehicle
{
public Car()
{
Console.WriteLine(“Car is being initialized.”);
}
}
}