Use XML Literals in C#?

后端 未结 5 1874
遇见更好的自我
遇见更好的自我 2020-12-05 23:16

Is it possible to add literal XML data within a C# code file? I\'m currently using a multiline string literal but it gets messy as you can see. Any better way of doing this?

5条回答
  •  执笔经年
    2020-12-05 23:39

    If the XML is big enough to get in the way, consider using a flat .xml file instead, either loaded from disk, or embedded as a resource. As long as you only load it once (perhaps in a static constructor) this will make no difference to performance. It will be considerably easier to maintain, as it will use the IDE's XML file editor. And it won't get in the way of your code.

提交回复
热议问题