C# component constructor in VS

I’m trying to put a code into the grasshopper c# component constructor:

 public class MyComponent : GH_Component
        public MyComponent ()
          : base("My Component", "MC",
              "For testing purposes",
              "List", "Group")
             private MyClass object = new MyClass();
             // It throws error CS1513: '} expected'

Am I putting the code in the wrong place? Where I could put a code which will be executed only at the creation of component? Similar to putting code into ‘Custom additional code’ in Grasshopper C# Script component?

Hi @Lukas_Mateja,

Maybe something more like this?

internal class MyObject
  public MyObject() { }

public class TestGhComponent : GH_Component
  private MyObject m_myobject;

  public TestGhComponent()
    : base("TestGh", "Nickname",
        "Category", "Subcategory")
    m_myobject = new MyObject();


– Dale