How to set the value of an enumeration?

Total Post:119

Points:835
C# 
C#
 979  View(s)
Ratings:
Rate this:

i have a problem setting the value od an enumeration. 

In my code I define this enumeration: 

    public enum PartType
    {
        Application,
        Operating_System,
        Hardware
    } 
    public PartType Part { get; set; }

Then, in the same class I try to set a value of this eumeration in this way (how I have read on the C# documentation):

 

   if (row["part"] == "a")
   {
        Part.Application;
   }

But it signed as error. Why? What am I missing? How can I solve?

  1. Post:378

    Points:2694
    Re: How to set the value of an enumeration?

    Hi goti, 


    It should be :

    Part = PartType.Application;

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!