Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: Wrapping one Enum inside another (ie. mirroring another enum/copying it...)

Here's my problem: I have an object that's referencing a DLL. I would like other objects to reference my object, without having to also include a reference to the DLL itself.

This is fine for the most part except there is an enum in the DLL that I would like to replicate. I could write out the enum line by line, but I'm wondering if there's a better way to do this.

ie.

Let's say the DLL's got the following enum:

public enum dllEnum
{
  value1,
  value2,
  value3
}

I could do the following:

public enum myEnum
{
  value1,
  value2,
  value3
}

or better yet:

public enum myEnum
{
  value1 = dllEnum.value1,
  value2 = dllEnum.value2,
  value3 = dllEnum.value3
}

But each of these cases has me writing out the entire enum out myself. I would rather just be able to wrap the entire enum as my own, preserving the indexes of the original enum.

Something along the lines of:

public enum myEnum
{
  Enum.GetValues(dllEnum)
}
like image 920
AlishahNovin Avatar asked Dec 02 '09 17:12

AlishahNovin


1 Answers

What you are asking has been discussed here:

Enum "Inheritance"

like image 64
Michael Edwards Avatar answered Oct 13 '22 00:10

Michael Edwards