语言

XmlException.LineNumber 属性

定义

获取指示发生错误的行号。 行号从 1 开始。

public:
 property int LineNumber { int get(); };
public int LineNumber { get; }
member this.LineNumber : int
Public ReadOnly Property LineNumber As Integer

属性值

指示发生错误的行号。

注解

尝试加载字符串 "<<foo>\r\nbar</foo>" 时,XML 将引发以下 XmlException 消息:

System.Xml.XmlException: 'Name cannot begin with the '<' character, hexadecimal value 0x3C. Line 1, position 2.'

显示行号是基于 1 的(在第一行中找到错误)。

适用于