![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# Enum IsDefined Method
The IsDefined method returns true if a given integral value, or its name as a string, is present in a specified enum.
The following is our enum −
enum Subjects { Maths, Science, English, Economics };
The above is initialized by default i.e.
Maths = 0, Science = 1, English = 2, Economics = 3
Therefore, when we will find 3 using IsDefined(), then it will return True as shown below −
Example
using System; public class Demo { enum Subjects { Maths, Science, English, Economics }; public static void Main() { object ob; ob = 3; Console.WriteLine("{0} = {1}", ob, Enum.IsDefined(typeof(Subjects), ob)); } }
Output
3 = True
Advertisements