Q:

difference of property in interface and class

interface IVehicle
{
    int Id { get; set; }

    string Name { get; set; }

    void Print();          
}

class Car : IVehicle
{
    public int Id { get; set; }

    public string Name { get; set; }

    public void Print()
    {
        Console.WriteLine($"Id {Id} Name {Name}");
    }
}

As we all know interface can only declare the members and we implement those members in classes which inherit from that interface.
So what is the difference then? Why do I have to re-declare the properties in the class? Can't it use the declarations from the interface?

A:

An interface defines a contract that classes implementing it must adhere to in order to compile. An interface does not say how the implementation must be done, only that it satisfies the interface. For example, you've created a string property for Name that must expose a getter and setter.
Your Car implementation uses autoproperties to satisfy the interface. However, you could have written your car like this:
class Car : IVehicle
{
    public int Id { get; set; }

    private string _name;

    public string Name { get { return _name; } set { _name = value; } }

    public void Print()
    {
        Console.WriteLine($"Id {Id} Name {Name}");
    }
}

and that would be perfectly valid since it still publicly exposes a string property Name with getters and setters.
When you first a create a car (Car myCar = new Car();, it will have default values for its properties. But you can modify those values:
IVehicle myCar = new Car();
myCar.Name = "The General";

//alternate syntax using object initializer
IVehicle schoolBus = new Car { Name = "Magic School Bus" };

