safaribook-pro-aspnet-mvc3/chap5_essential_language_fe.../essential_csharp_features/Program.cs

42 lines
1.0 KiB
C#

using System;
using System.Diagnostics;
namespace automatically_implemented_properties
{
class Program
{
static void Main(string[] args)
{
// 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)
{
// ... statements to process product in some way
}
}
public class Product
{
private string name;
public int ProductID { get; set; }
public string Name
{
get { return ProductID + name; }
set { name = value; }
}
public string Description { get; set; }
public decimal Price { get; set; }
public string Category { set; get; }
}
}