+ 1
What could I change or add to make the code shorter or even better?
2 Réponses
+ 3
Sun1 ,
I think it'd be better if you use property with setter and getter in the Car class instead of this.[item] = [item] and return it, like this:
public string Model {get; set;}
/*get; set; is the shortcut of:
private string model;
`get {return model;}
set {model = value;}`
*/
[...]
Here's an example of property using the code you provided:
https://code.sololearn.com/cYkFPR4q6Yq6/?ref=app
Learn more about C# Properties here:
https://www.w3schools.com/cs/cs_properties.php
0
Dragon RB Thank you!