<p>What is the most efficient way in C# 2.0 to check each character in a string and return true if they are all valid hexadecimal characters and false otherwise?</p>
<h3>Example</h3>
<pre><code>void Test()
{
    OnlyHexInString(&quot;123ABC&quot;); // Returns true
    OnlyHexInString(&quot;123def&quot;); // Returns true
    OnlyHexInString(&quot;123g&quot;); // Returns false
}

bool OnlyHexInString(string text)
{
    // Most efficient algorithm to check each digit in C# 2.0 goes here
}
</code></pre>

I use
```
Int32.TryParse()
```
to do this.
Here's the MSDN page on it
.