changing the value of parameters in constructor

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
 
D

Dmytro Lapshyn [MVP]

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) )
 
G

Guest

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top