目前我拥有的代码正在生成类似的属性
private int integerProperty
{
get
{
return integerField;
}
set
{
integerField = value;
}
}
我希望属性很简单,比如......
private int integerProperty
{
get;
set;
}
我的代码是
CodeMemberProperty property1 = new CodeMemberProperty();
property1.GetStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "integerField")));
property1.SetStatements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "integerField"),new CodePropertySetValueReferenceExpression()));
type1.Members.Add(property1);
任何人请帮忙。提前致谢。