dimanche 26 avril 2015

copy values from enums in different namespaces


I have two object MyObj and MyObjDTO both have same property StarRating of type enum.

public class MyObj
{
    public enum StarRating {
         One = 1,
         Two = 2
    }
}

public class MyObjDTO
{
    public enum StarRating {
         One = 1,
         Two = 2
    }
}

I want to assign value from MyObj to MyObjDTO. I tried

var dto = ... loaded dto object

var data = new MyObj
            {
                ...
                RatingStatus = (int)dto.RatingStatus
            };

But It doesnt work, I'm getting underlined error under int and simple

 RatingStatus = dto.RatingStatus

doesnt work either.


Aucun commentaire:

Enregistrer un commentaire