+ 1

What could I change or add to make the code shorter or even better?

https://code.sololearn.com/czR8W2Rex955/?ref=app

8th Oct 2023, 7:13 AM
Sun1
2 Antworten
+ 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
8th Oct 2023, 9:18 AM
Dragon RB
Dragon RB - avatar
0
Dragon RB Thank you!
8th Oct 2023, 3:25 PM
Sun1