It means that you're casting your object to TextBox
(or Control
)
In your example, you wrote this:
if (tb is TextBox)
{
((TextBox)tb).Text = "Hello world";
}
If tb
is a TextBox
, then you cast your object to a TextBox
to have access to its methods and set values as you want.
You can do a explicit cast, which will throw an exception if the cast fails, OR you can convert your object, using the as operator
, which will return null
if the conversion fails, like this:
(tb as TextBox).Text = "Hello world";