.Net Interview Questions and Answers

Search:

How to convert string to ENUM value ?( .NET interview questions with answers)

By : Shiv Prasad Koirala | Feb 5th, 2014 | Views : 2448 | Comments : 0 Bookmark and Share

Note this question can also asked in a different format "Explain Enum.Parse() function ?".


Many times we would like to convert string in to ENUM objects. For example let's say you have a COLOR Enum and you would like to pass string "Red" and get ENUM object "color.Red".


"ENUM.Parse" method parses string to an ENUM value. Like in the below code we pass "Red" string value and it gets type casted to enum which has green enum as a constant.


MyColors EnumColors = (MyColors)Enum.Parse(typeof(MyColors), "Red");


You can see the below video created by www.questpond.com team which demonstrates how string can be converted to a ENUM constant.


 
Rate this Article :
1 Star
2 Stars
3 Stars
4 Stars
5 Stars
1 1 1 2 1
 
 
 
 

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

In this article we will explain .NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala.... Read More

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

In this article we will explain what is the difference between Stored Procedures and Function.For more articles and videos visit us on www.questpond.com... Read More

Explain MVC application life cycle?

In this article we will explain MVC application life cycle.For more articles and videos visit us on www.questpond.com... Read More

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

In this article we will explain How Singleton is different from Static class.... Read More

WCF interview questions and answers: - What is the difference between Service endpoint and Client endpoint?

In this article we will explain What is the difference between Service endpoint and Client endpoint.... Read More

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

In this article we will explain .NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala.... Read More

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

In this article we will explain what is the difference between Stored Procedures and Function.For more articles and videos visit us on www.questpond.com... Read More

Explain MVC application life cycle?

In this article we will explain MVC application life cycle.For more articles and videos visit us on www.questpond.com... Read More

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

In this article we will explain How Singleton is different from Static class.... Read More

WCF interview questions and answers: - What is the difference between Service endpoint and Client endpoint?

In this article we will explain What is the difference between Service endpoint and Client endpoint.... Read More

Article Categories

Learn in Hindi