Hello, I hope can help me, the problem is this, I want to initialize a member variable in the constructor of a class with CodeDOM to achieve something like this:
Public Sub New()
MyBase.New
Me._myOfficeApp = New Microsoft.Office.Interop.Excel.Application
End Sub
The code I use to do that is:
' Create a Public Class Constructor
Dim aConstructor As New CodeConstructor()
aConstructor.Attributes = MemberAttributes.Public
Dim ca As New CodeAssignStatement()
ca.Left = New CodeFieldReferenceExpression(New CodeThisReferenceExpression(), "_myOfficeApp")
ca.Right = New CodeTypeReferenceExpression("New Microsoft.Office.Interop.Excel.Application")
aConstructor.Statements.Add(ca)
My question is that I do not think I'm doing it the right way, maybe you could help me about this,
I think there is another way to initialize the variable without having to manually put the "New" statement.
Sorry for my English
I really hope can help me. best regards