object myObj = new object(); if(myObj.GetType() == typeof(object)) { Console.WriteLine("myObj is of type object"); }
object myObj = "Hello World"; if(myObj is string) { Console.WriteLine("myObj is of type string"); }Here, we create an instance of the Object class and assign a string value to it. We then use the 'is' keyword to check if it is of the string type and print a message accordingly. These examples are part of the C# standard library (mscorlib.dll), which is included in the .NET Framework and .NET Core.