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

42 lines
1.0 KiB
C#
Raw Normal View History

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;
2021-07-05 15:38:10 +10:00
public int ProductID { get; set; }
public string Name
{
2021-07-05 15:38:10 +10:00
get { return ProductID + name; }
set { name = value; }
}
2021-07-05 15:38:10 +10:00
public string Description { get; set; }
public decimal Price { get; set; }
public string Category { set; get; }
}
}