In C#, what does "Customer cust = new Customer();" do?

c#

Solution

It declares a Customer and then initializes it.

Customer cust; //declares a new variable of Customer type

cust = new Customer(); //Initializes that variable to a new Customer().

new creates the actual object, cust hold's a reference to it.

The empty parentheses indicates that the construction of the Customer object is being passed no parameters, otherwise there would be a comma separated list of parameters within the parenthesis.

Problem

``` Customer cust = new Customer(); ``` `Customer` is a class. `cust` is an assigned name. I'm not sure what `Customer()` does... What does this line do? Why do we need it? Isn't having `Customer` and `Customer()` a bit repetitive?

Original source