How do I rewrite this into C#

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!

I have this statement in VB.net and I want to have it in C#. I have done
someting but don't know
how I rewrite this CType in C#

Dim strId As String = CType(GridView1.Rows(e.RowIndex).Cells(2).Controls(0),
TextBox).Text
string strID = ???
GridView1.Rows[e.RowIndex].Cells[2].Controls[0],???

//Tony
 
Tony said:
Hello!

I have this statement in VB.net and I want to have it in C#. I have done
someting but don't know how I rewrite this CType in C#

Dim strId As String =
CType(GridView1.Rows(e.RowIndex).Cells(2).Controls(0), TextBox).Text
string strID = ???
GridView1.Rows[e.RowIndex].Cells[2].Controls[0],???

string strId =
((TextBox)GridView1.Rows(e.RowIndex).Cells(2).Controls(0)).Text;
 
I have this statement in VB.net and I want to have it in C#. I have done
someting but don't know
how I rewrite this CType in C#

Dim strId As String =
CType(GridView1.Rows(e.RowIndex).Cells(2).Controls(0), TextBox).Text
string strID = ???
GridView1.Rows[e.RowIndex].Cells[2].Controls[0],???

Jason already explained how to convert VB.NET CType
to C# cast.

But I will like to add that I think the code should
be improved a bit regarding readability (and maybe
also robustness).

Arne
 
Back
Top