Using selenium.GetSelectedIndex in Webdriver

Here is the Selenium RC code for selenium.GetSelectedIndex in Webdriver. This code is in Visual Studio C# public string GetSelectedIndex(string xpath) { string text=””; int statenum = Convert.ToInt32(GetXpathCount(xpath+”/option”)); for (int i = 1; i < statenum; i++) { if (IsElementPresent(xpath+”/option[” + i + “][@selected]”)) { text = Convert.ToString((i – 1)); } } return text; }