XmlReader.ReadString 是否已弃用或已过时? [英] Is XmlReader.ReadString deprecated or obsoleted?
问题描述
我想使用 System.Xml.XmlReader.ReadString()
,但我注意到它没有出现在 Intellisense 中,因为该函数是用 [EditorBrowsable(EditorBrowsableState.从不)]
.尽管没有被标记为 [Obsolete]
,但我认为微软不希望我使用它.
我在 MSDN 上找不到任何提及.我应该用什么代替?在 ILSpy 中,我看到 ReadElementContentAsString()
和 ReadContentAsString()
.这是我想用的吗?我使用的是 .Net 4.5.
如果相关,这个问题是由这个答案提示的:https://stackoverflow.com/a/625463/47589
It 未弃用.我认为你的推理是正确的.框架开发人员可能将其标记为 [EditorBrowsable(EditorBrowsableState.Never)]
以便它不会出现在智能感知中,并推动"您使用更好的替代方案,这可能是 ReadContentAsString代码>.
根据 Inpage&q">><块引用> 也许这就是您在 IL 中看到 见相关:System.ComponentModel.EditorBrowsable 是白痴写的 I'm wanting to use I can't find any mention of this on MSDN. What should I be using instead? In ILSpy I see In case it's relevant, this question was prompted by this answer: https://stackoverflow.com/a/625463/47589 It isn't deprecated. I think your reasoning is correct. The framework developers likely marked it as According to C# In a Nutshell. Maybe that's why you are seeing See related : System.ComponentModel.EditorBrowsable was written by idiots 这篇关于XmlReader.ReadString 是否已弃用或已过时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!ReadString
和 ReadElementString
的行为类似于 ReadContentAsString
和 ReadElementContentAsString
,除了它们抛出一个Exception
如果有多个单个文本节点元素.通常,应避免使用这些方法,因为它们会抛出如果元素包含注释,则异常.ReadContentAsString
的原因,因为框架在内部将所有对 ReadString
的调用转换为 ReadContentAsString
和框架开发人员有意将 ReadString
从智能感知中隐藏起来.System.Xml.XmlReader.ReadString()
, but I noticed it doesn't show up in Intellisense because the function is decorated with [EditorBrowsable(EditorBrowsableState.Never)]
. Despite not being marked as [Obsolete]
, I assume Microsoft doesn't want me to use it.ReadElementContentAsString()
and ReadContentAsString()
. Is this what I want to use instead? I am using .Net 4.5.[EditorBrowsable(EditorBrowsableState.Never)]
so that it doesn't show up in intellisense, and "nudges" you to use a better alternative, which maybe ReadContentAsString
.
ReadString
and ReadElementString
behave like ReadContentAsString
and ReadElementContentAsString
, except that they throw an
Exception
if there's more than a single text node within the
element. In general, these methods should be avoided, as they throw an
exception if an element contains a comment.ReadContentAsString
in the IL, because the framework is internally converting all calls to ReadString
to ReadContentAsString
and the Framework developers intentionally hid ReadString
from the intellisense.