ASP.NET Tutorial/LINQ/Automatic Properties — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 18:30, 26 мая 2010

Understanding Automatic Properties

   <source lang="csharp">

Automatic properties provide you with a shorthand method for defining a new property. You can"t add any logic to the Getters and Setters for an automatic property. You can"t create read-only automatic properties. File: App_Code\AutomaticProperties.cs public class AutomaticProperties {

   // Automatic Properties
   public int Id { get; set; }
   public string Description { get; set; }
   // Normal Property
   private decimal _Price;
   public decimal Price
   {
       get { return _Price; }
       set { _Price = value; }
   }

}</source>