C# 具有 XML 架构的 XElement 对象的 IntelliSense

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21912/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-01 09:08:46  来源:igfitidea点击:

IntelliSense for XElement objects with XML schema

提问by Philippe

Reading an article called "Increase LINQ Query Performance"in July's MSDN magazine, the author states that using an Importsin VB providing a path to schema in the current project will turn IntelliSense on for XElement. In the code provided, he uses statements like xelement.@nameto retreive attributes values and so on.

在阅读7 月的 MSDN 杂志上的一篇名为“提高 LINQ 查询性能”的文章时,作者指出,Imports在当前项目中使用提供模式路径的 VB 中的an将为 XElement 启用 IntelliSense。在提供的代码中,他使用了诸如xelement.@name检索属性值等语句。

I did not try this out myself in VB but I would like to use that in C#. This really looks like LINQ to XSD.

我自己没有在 VB 中尝试过这个,但我想在 C# 中使用它。这真的很像 LINQ to XSD。

Is there any equivalent in C#? It seems that it is not possible to use a namespace inside C# code, there is no usingequivalent to this Importstatement.

C# 中是否有任何等价物?似乎不可能在 C# 代码中使用命名空间,没有using与此Import声明等效的内容。

采纳答案by John Sheehan

This post claims to have a link to a video that shows how to use VB9's XML Literals in C#. However, it only really discusses them and from what I can gather, you cannot use them in C#. http://blogs.msdn.com/bethmassi/archive/2008/07/03/teched-panel-vb-xml-literals-for-c-developers.aspx

这篇文章声称有一个视频链接,该视频展示了如何在 C# 中使用 VB9 的 XML 文字。但是,它只是真正讨论了它们,据我所知,您不能在 C# 中使用它们。http://blogs.msdn.com/bethmassi/archive/2008/07/03/teched-panel-vb-xml-literals-for-c-developers.aspx