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(...)

    }
} 
0

1 Answer 1

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
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

u are right .. i updated answer

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.