TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Check Object Type in C#
Abrar Ahmad Ansari
Mar 25
2015
Code
2.2
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
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"
);
}
}
}
}
C#
Check Object Type in C#