5.1.2 Using Object and Colleciton Initializers: create object and assign value with initializer
parent
93255dc698
commit
6301eccf0a
|
@ -7,18 +7,15 @@ namespace automatically_implemented_properties
|
|||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// create a new Product object
|
||||
Product myProduct = new Product();
|
||||
|
||||
// set the property value
|
||||
myProduct.ProductID = 100;
|
||||
myProduct.Name = "Kayak";
|
||||
myProduct.Description = "A boat for one person";
|
||||
myProduct.Price = 275M;
|
||||
myProduct.Category = "Watersports";
|
||||
|
||||
// process the property
|
||||
ProcessProduct(myProduct);
|
||||
// create a new Product object and use method on it
|
||||
ProcessProduct(new Product
|
||||
{
|
||||
ProductID = 100,
|
||||
Name = "Kayak",
|
||||
Description = "A boat for one person",
|
||||
Price = 275M,
|
||||
Category = "Watersports"
|
||||
});
|
||||
}
|
||||
|
||||
private static void ProcessProduct(Product prodParam)
|
||||
|
|
Loading…
Reference in New Issue