How do I rewrite this into C#

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
 
J

Jason Keats

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;
 
A

Arne Vajhøj

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top