本文整理汇总了C#中XObject.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# XObject.ToString方法的具体用法?C# XObject.ToString怎么用?C# XObject.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XObject
的用法示例。
在下文中一共展示了XObject.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ThrowParse
internal static void ThrowParse(Exception ex, XObject xObj, string typeStr)
{
if (ex is FormatException || ex is OverflowException) {
// FormatException also thrown when string is empty
string message = "Could not parse " + typeStr + " in XML item: " + xObj.ToString ();
ThrowXmlExceptionWithLineInfo (message, ex, xObj);
}
}
示例2: ParseHexInt
// Used to parse both element and attribute content.
// Both XElement and XAttribute derive from XObject but XObject has no content so cannot be used.
/// <summary>
/// Parses hex number e.g."0x123af". Prefix "0x" is required.
/// </summary>
internal static int ParseHexInt(string strToParse, XObject xObj)
{
const string HexPrefix = "0x";
// Prefix "0x" required in RomRaider-format
// but not allowed in int.Parse(...) even though using NumberStyles.HexNumber.
int index0x = strToParse.IndexOf (HexPrefix);
if (index0x < 0) {
string message = "Prefix '" + HexPrefix + "' missing in XML item: " + xObj.ToString ();
ThrowXmlExceptionWithLineInfo (message, null, xObj);
}
try {
return int.Parse (strToParse.Substring (index0x + HexPrefix.Length), System.Globalization.NumberStyles.HexNumber, NumberFormatInfoInvariant);
} catch (Exception ex) {
ThrowParse (ex, xObj, "hex integer");
throw;
}
}