Skip to content

Instantly share code, notes, and snippets.

View bhargavrpatel's full-sized avatar
💭
I may be slow to respond.

Bhargav Patel bhargavrpatel

💭
I may be slow to respond.
  • Instacart
  • Toronto, Canada
View GitHub Profile
@bhargavrpatel
bhargavrpatel / Using Initializers in C#
Last active August 29, 2015 13:57
Something that would go inside your Models
/* CASE I: OBJECTS */
// BEFORE
public ViewResult CreateProduct() {
// create a new Product object
Product myProduct = new Product();
// set the property values
myProduct.ProductID = 100;
myProduct.Name = "Kayak";
myProduct.Description = "A boat for one person";
@bhargavrpatel
bhargavrpatel / AFTER
Last active August 29, 2015 13:57
Simplifying C# properties
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; }
}
}