changing the value of parameters in constructor

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I want to create a new constructor in a class that inherits from another...
in VB.Net

I still want to call the base class after some code has 'manipulated' the
parameters

VB is telling me i carn't as MyBase.New needs to be the first call in the
New methd....

But how else could i do this?

Do i need to create an abstract class....?

Public Sub New(ByVal Domain As string, ByVal username As String, ByVal
password As String)

'code that manipulates string parameters

MyBase.New( parameter1, parameter2, parameter3 )

End Sub
 
Hi,

Not sure that's gonna work in VB .NET, but give the following approach a try
(the specific parameter modifications are given for illustrative purposes
only, the key is the inline modification of the parameters):

Public Sub New(ByVal Domain As string, ByVal username As String, ByVal
password As String)

MyBase.New( String.Concat(Domain, "\", username),
String.Trim(username), String.Trim(password) )
 
Yes...

Of course.... ;-)

Many thanks

Dmytro Lapshyn said:
Hi,

Not sure that's gonna work in VB .NET, but give the following approach a try
(the specific parameter modifications are given for illustrative purposes
only, the key is the inline modification of the parameters):

Public Sub New(ByVal Domain As string, ByVal username As String, ByVal
password As String)

MyBase.New( String.Concat(Domain, "\", username),
String.Trim(username), String.Trim(password) )
 
Back
Top