ASP.NET Tutorial/LINQ/Initializers — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 14:58, 26 мая 2010
Understanding Initializers
<source lang="csharp">
File: App_Code\Product.cs public class Product {
public int Id { get; set; } public string Name { get; set; } public decimal Price { get; set; }
} in .NET Framework 2.0 (with C#):
Product product1 = new Product(); product1.Id = 1; product1.Name = "Laptop Computer"; product1.Price = 800.00m;
Here"s how you use initializers in C#: Product product2 = new Product {Id=1, Name="Laptop Computer", Price=800.00m};</source>