Work-around for C# CodeDom causing stack-overflow (CS1647) in csc.exe?

前端 未结 5 2086
滥情空心
滥情空心 2021-01-12 14:20

I\'ve got a situation where I need to generate a class with a large string const. Code outside of my control causes my generated CodeDom tree to be emitted to C# source and

5条回答
  •  逝去的感伤
    2021-01-12 15:12

    Note that if you declare the string as const, it will be copied in each assembly that uses this string in its code.

    You may be better off with static readonly.

    Another way would be to declare a readonly property that returns the string.

提交回复
热议问题