有没有一种方法可以在 C# 代码中定义多行 XML,而无需更改“”到“”?
我希望能够将 XML 块粘贴到我的 C# 代码中。
但是,我能做的最好的就是以下,但随后我必须搜索并将“替换为””。
有吗有没有一种方法可以在 C# 代码中定义多行 XML,而无需像这样更改 XML 文本?
public static string GetXml1()
{
return @"
<Customer>
<FirstName status=""required"">Jim</FirstName>
<LastName status=""required"">Smith</LastName>
</Customer>
";
}
I would like to be able to paste chunks of XML into my C# code.
However, the best I can do is the following, but then I have to search and replace " with "".
Is there a way to define multiline XML in C# code without having to alter the XML text like this?
public static string GetXml1()
{
return @"
<Customer>
<FirstName status=""required"">Jim</FirstName>
<LastName status=""required"">Smith</LastName>
</Customer>
";
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 XML 存储为字符串资源,然后使用
ResourceManager
检索 XML。Store the XML as a string resource then retrieve the XML as using
ResourceManager
.不一定是您所要求的,但如果行对齐,“框/列选择”可能会有所帮助。只需按住“Alt”键,同时使用鼠标选择要删除的“,然后按删除即可。
Not necessarily what you are askin for, but Box/Column Select might help if the lines are alligned. Just hold down the 'Alt'-key while you use the mouse to select the " you want to remove and press delete.