在 .NET CodeDom 中分配别名类型名称会导致 @ 符号输出

问题描述

使用 .NET CodeDom 时:

CodeMemberField param = new CodeMemberField();
string paramType = "string";
param.Attributes = MemberAttributes.Assembly;
param.Name = "SampleName";
param.Type = new CodeTypeReference(paramType);

以上代码输出为:

internal @string SampleName;

这对于任何别名类型名称(例如 int、bool 等)都会发生,但对实际类型(例如 String、Int32、Point 等)工作正常。如何摆脱 @ 符号?我不能在 typeof 构造函数中使用 CodeTypeReference,它必须是一个字符串变量。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)