简体   繁体   中英

How to pass an interface to a constructor in vb.net

I am trying to convert some code from c# to vb.net. The whole code is in http://www.codeproject.com/Articles/474418/DataGridViewplus-e2-80-93plusStackedplusHeader . I almost have it but I am running into a problem with the constructor. In C# it is passing in an interface. Like the following

    public StackedHeaderDecorator(IStackedHeaderGenerator objStackedHeaderGenerator, DataGridView objDataGrid)
        : this(objDataGrid)
    {
        this.objStackedHeaderGenerator = objStackedHeaderGenerator;
    }

I am not sure how to convert this to vb.net. I would really appreciate it if someone could tell me how to write the code to pass an integerface to a constructor.

You pass an interface reference just like you'd pass any type:

Sub New(objStackedHeaderGenerator As IStackedHeaderGenerator, objDataGrid As DataGridView)

    Me.New(objDataGrid)

    Me.objStackedHeaderGenerator = objStackedHeaderGenerator

End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM