日期:2014-05-17  浏览次数:20833 次

关于C#字段属性
请问

 public class Product
    {
        public string Name{get; set;}
        public string Category { get; set; }
        public double Price { get; set; }
    }


和 

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

namespace Model
{
    public class Product
    {
        public string _Name;
        public string _Category;
        public double _Price;


        public string Name
        {
            set
            {
                _Name = value;
            }
            get
            {
                return _Name;
            }
        }
        public string Category
        {
            set
            {
                _Category = value;
            }
            get
            {
                return _Category;
            }
        }
        public double Price
        {
            set
            {
                _Price = value;
            }
            get
            {
                return _Price;
            }
        }
    }
}

============================================================

有什么区别么 各有什么好处和作用呢  初