C# Generics function
Can someone explain this behavior in Generics?

I have a generic function in C#

    protected virtual void LoadFieldDataEditor <T> (ref T control, string strFieldName) where T : Control
    {
      //T can be different types of controls inheriting from System.Web.UI.Control
      if (control is TextBox)
      {
       //This line gives an error
       //((TextBox)control).Text = "test";
    
       //This line works! 
       (control as TextBox).Text = "Test";
      }
    }

On a side note, can I use switch case when I am doing a "Control is TextBox" type of checking?
C# Generics function
===

Can someone explain this behavior in Generics?

I have a generic function in C#

    protected virtual void LoadFieldDataEditor <T> (ref T control, string strFieldName) where T : Control
    {
      //T can be different types of controls inheriting from System.Web.UI.Control
      if (control is TextBox)
      {
       //This line gives an error
       //((TextBox)control).Text = "test";
    
       //This line works! 
       (control as TextBox).Text = "Test";
      }
    }

On a side note, can I use switch case when I am doing a "Control is TextBox" type of checking?