Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Check Object Type in C#
WhatsApp
Abrar Ahmad Ansari
Mar 25
2015
2.3
k
0
0
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#
Up Next
Check Object Type in C#