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

36 lines
876 B
C#

using System;
namespace automatically_implemented_properties
{
class Program
{
static void Main(string[] args)
{
// create a new Product object
Product myProduct = new Product();
// set the property value
myProduct.Name = "Kayak";
// get the property
string produtName = myProduct.Name;
Console.WriteLine("Product name: {0}", produtName);
}
}
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; }
}
}