What's the C# version of DirectCast?

This is the VB version:

Dim t As TextBox = DirectCast(FormView1.FindControl("DataTextBox"), TextBox)

t.Text = "hello"

How do I do the same thing in C# I don't see the DirectCast available in C#.




Answer this question

What's the C# version of DirectCast?

  • pnb

    Thanks!

  • Bruno B.

    TextBox t = (TextBox)o;
    t.Text = "hello";

    Where o is a reference to the object you want to typecast.

    So for yours...

    TextBox t = (TextBox)FormView1.FindControl("DataTextBox");
    t.Text = "hello";



  • What's the C# version of DirectCast?