本文整理汇总了C#中StringScanner.ParseHexValue方法的典型用法代码示例。如果您正苦于以下问题:C# StringScanner.ParseHexValue方法的具体用法?C# StringScanner.ParseHexValue怎么用?C# StringScanner.ParseHexValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringScanner
的用法示例。
在下文中一共展示了StringScanner.ParseHexValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Decode
/// <summary>
/// Decodes the given hex codedStr, sets the decodedBuffer to the resulting decoded byte array and returns true if the operation was successful.
/// </summary>
/// <param name="codedStr">the string containing the encoded characters.</param>
/// <param name="decodedBuffer">the output byte array variable that will be set to a new array containing the decoded bytes</param>
/// <returns>true if the operation was successful,false otherwise. The contents of the resulting decoded buffer are not defined if the return value is false</returns>
public override bool Decode(string codedStr, out byte[] decodedBuffer)
{
List<byte> byteBuilder = new List<byte>();
bool success = true;
StringScanner ss = new StringScanner(codedStr);
while (success && !ss.IsAtEnd)
{
int value;
success = ss.ParseHexValue(out value, 2, 2, true, true, false);
success &= (value >= 0 && value <= 255);
if (success)
byteBuilder.Add(unchecked((byte)value));
}
decodedBuffer = byteBuilder.ToArray();
return success;
}