using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CtorDemo
{
    public class Curry
    {
//也可以没有构造函数
public Curry() { } public string MainIngredient { get; set; } public string Style { get; set; } public int Spiciness { get; set; } } class Program { static void Main(string[] args) { Curry cur1 = new Curry(); cur1.MainIngredient = "Panic1"; cur1.Style = "Red1"; cur1.Spiciness = 9; Curry cur2 = new Curry { MainIngredient = "Panic", Style = "Red", Spiciness = 8 }; Console.WriteLine(cur2.MainIngredient); Console.WriteLine(cur2.Style); Console.WriteLine(cur2.Spiciness); Console.ReadLine(); } } }

 

posted on 2013-11-02 16:17  zzunstu  阅读(169)  评论(0编辑  收藏  举报