9
public class bar
{
   public bar(list<int> id, String x, int size, byte[] bytes)
   {
     ...
   }
}

public class Foo: Bar
{
    public Foo(list<int> id, String x, someEnumType y):
     base(id, x, sizeof(someEnumType), y)
    {
        //some functionality
    }
}

As you see in the above code I need to convert someEnumType to byte array type before calling base class constructor. Is there a way to do it? Something like:

public class Foo: Bar
{
    public Foo(list<int> id, String x, someEnumType y)
    {
        //someEnumType to byte array
        base(...)

    }
} 
user2528718
  • 125
  • 6

1 Answers1

4

Just create a method in your derived class and call it....

public class bar
{
   public bar(list<int> id, String x, int size, byte[] bytes)
   {
     ...
   }
}

public class Foo: Bar
{
    public Foo(list<int> id, String x, someEnumType y):
     base(id, x, sizeof(someEnumType), Convert(y))
    {
        //some functionality
    }

    public static byte[] Convert(SomeEnumType type)
    {
        // do convert
    }
}
puko
  • 2,819
  • 4
  • 18
  • 27