title: Auto increment ID C#
body: <p>I am busy with a really small console application for c#. I am just new into c# and i'm only familiar with Java. My school gave the assignment to create a console application that simulates a car dealer. I already wrote a bunch of code to add cars by console. Things like brand and type and max speed are already implemented. The only thing i still need to realize is the auto creation and incremental of an ID for a car. It has the be unique of course. </p>
  
  <p>My first approach was making the id field static and increment it in the constructor so that each time the object gets created the id gets ++;</p>
  
  <p>I saw allot of people on stackoverflow doing allot of things but the solutions did not work or the where to big.</p>
  
  <p>This is my code;</p>
  
  <pre><code>   class Car : Vehicle
  {
      public string brand { get; set; }
      public string type { get; set; }
      public int maxSpeed { get; set; }
      public double price { get; set; }
      public static int carID { get; set; }
  
  
  
      public Car(string _brand, string _type, int _maxspeed, double _price)
      {
          this.brand = _brand;
          this.type = _type;
          this.maxSpeed = _maxspeed;
          this.price = _price;
          this.carID++;
  
      }
  }
  </code></pre>
  
  <p>I added 3 cars to my list but the result is that all cars have ID 3;</p>
  
  <p>Maybe someone could help me, thanks in advance.</p>