ASP.NET Tutorial/LINQ/Initializers
Версия от 15:30, 26 мая 2010; (обсуждение)
Understanding Initializers
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};