- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication3
- {
- class Product
- {
- public string ProductName
- {
- get;
- set;
- }
- }
- class Customer
- {
- public string CustomerName
- {
- get;
- set;
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- object obj1 = new Customer();
- if (obj1 is Product) // checking Object Type
- {
- Console.WriteLine("Obj1 is a Product Type Object");
- }
- if (obj1 is Customer) //checking Object Type
- {
- Console.WriteLine("Obj1 is a Customer Type Object");
- }
- }
- }
- }
This code snippet describes about some scenario where we want to check Object Type.
