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