Last active
August 29, 2015 13:57
-
-
Save bhargavrpatel/9562495 to your computer and use it in GitHub Desktop.
Simplifying C# properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace LanguageFeatures.Models { | |
public class Product { | |
public int ProductID { get; set; } | |
public string Name { get; set; } | |
public string Description { get; set; } | |
public decimal Price { get; set; } | |
public string Category { set; get; } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Getter and setter etc have to be set manually like this. | |
namespace LanguageFeatures.Models { | |
public class Product { | |
private int productID; | |
private string name; | |
private string description; | |
private decimal price; | |
private string category; | |
public int ProductID { | |
get { return productID; } | |
set { productID = value; } | |
} | |
public string Name { | |
get { return name; } | |
set { name = value; } | |
} | |
public string Description { | |
get { return description; } | |
set { description = value; } | |
} | |
//...and so on... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment