P
Phil Streiff
I tried to convert this VB function to C#:
VB------------------------------------------------
Function GetSelectedIndex(CID as String) as Integer
Dim iLoop as Integer
Dim dt as DataTable = ddlDataSet.Tables("Categories")
For iLoop = 0 to dt.Rows.Count - 1
If Int32.Parse(CID) =
Int32.Parse(dt.Rows(iLoop)("FAQCategoryID")) then
Return iLoop
End If
Next iLoop
End Function
--------------------------------------------------
converted to C#-----------------------------------
public int GetSelectedIndex(string CID) {
int iLoop;
DataTable dt = ddlDataSet.Tables["Categories"];
for (iLoop = 0; iLoop <= dt.Rows.Count - 1; iLoop++)
{
if (Int32.Parse(CID) ==
Int32.Parse(dt.Rows[iLoop]["FAQCategoryID"]))
{
return iLoop;
}
}
}
--------------------------------------------------
but I get the following error on the "if" statement:
CS1502: The best overloaded method match for 'int.Parse(string)' has
some invalid arguments
Can anyone see what I am doing wrong and guide me in the right
direction?
This is in an inline .aspx page
Thanks in advance,
Phil
VB------------------------------------------------
Function GetSelectedIndex(CID as String) as Integer
Dim iLoop as Integer
Dim dt as DataTable = ddlDataSet.Tables("Categories")
For iLoop = 0 to dt.Rows.Count - 1
If Int32.Parse(CID) =
Int32.Parse(dt.Rows(iLoop)("FAQCategoryID")) then
Return iLoop
End If
Next iLoop
End Function
--------------------------------------------------
converted to C#-----------------------------------
public int GetSelectedIndex(string CID) {
int iLoop;
DataTable dt = ddlDataSet.Tables["Categories"];
for (iLoop = 0; iLoop <= dt.Rows.Count - 1; iLoop++)
{
if (Int32.Parse(CID) ==
Int32.Parse(dt.Rows[iLoop]["FAQCategoryID"]))
{
return iLoop;
}
}
}
--------------------------------------------------
but I get the following error on the "if" statement:
CS1502: The best overloaded method match for 'int.Parse(string)' has
some invalid arguments
Can anyone see what I am doing wrong and guide me in the right
direction?
This is in an inline .aspx page
Thanks in advance,
Phil