csharp check if object can be cast to type

Code Example - csharp check if object can be cast to type

                
                        var myObject = something as String;

if (myObject != null)
{
  // successfully cast
}
else
{
  // cast failed
}