在C#2.0中检查字符串中每个字符的最有效方法是什么?如果它们都是有效的十六进制字符则返回true,否则返回false?
void Test()
{
OnlyHexInString("123ABC"); // Returns true
OnlyHexInString("123def"); // Returns true
OnlyHexInString("123g"); // Returns false
}
bool OnlyHexInString(string text)
{
// Most efficient algorithm to check each digit in C# 2.0 goes here
}
Run Code Online (Sandbox Code Playgroud) Character.digit(char ch, int radix)
Run Code Online (Sandbox Code Playgroud)
返回指定基数中字符ch的数值.
c#中有等价的功能吗?