HighestBitSet in C#

I'm trying to optimize a a method that returns the highest bit set in a bit pattern, my current code is :


privateint HighestBitSet(int bitPattern)
{
return
(Convert.ToString(bitPattern, 2).Length - 1)
-
Convert.ToString(bitPattern, 2).IndexOf("1");
}



I know that in c++ i can use an assembler intruction to do this but in c# is not possible so, how can i optimize this ?
Tnks
[756 byte] By [IvoLeit?o] at [2007-12-16]
# 1
I have already found an answer in this site tnks anyway...
IvoLeit?o at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...