public class Fruit
{
// choose one
public int Id { get; set; }
public int FruitId get; set; } // redundant or usefully more descriptive?
// choose one
public string Name { get; set; }
public string FruitName { get; set;} // redundant or usefully more descriptive?
public string Fruit { get; set; } // or what about this?
}
哪個是您的水果識別號碼和名稱的首選約定?爲什麼?還有其他例子,你會回答不同嗎?何時,如果有的話,一個屬性的名稱是否包含該類的名稱?
雖然我同意你的看法,也有在BCL許多屬性包含類的名稱(或它的一部分):PropertyInfo.PropertyType,DbParameter.ParameterName ... – 2009-11-28 23:53:01