Class constructor issue

  • Thread starter Thread starter james
  • Start date Start date
J

james

I have a issue in implementing my objetcs.

Say I have class called Account. And I have required field which is
accountname.

public Account(string accountName)
: this()
{
_accountName = accountName;
}

So say within the application I want to change the accountName of the
account object.

Say I have

Account account = new Account("myaccount");



and in some where else in the program I need to change the
accountName.

How can I do that,
 
Hi!

You didn't specify, how _accountName is defined, but I'd suggest to put
a public property around, if you really need to change it.

Cheers,
Nessi

=== original message ===
from: james
date: 2011-07-21 15:01
 
I have a issue in implementing my objetcs.

Say I have class called Account. And I have required field which is
accountname.

public Account(string accountName)
: this()
{
_accountName = accountName;
}

So say within the application I want to change the accountName of the
account object.

Say I have

Account account = new Account("myaccount");



and in some where else in the program I need to change the
accountName.

How can I do that,

You need a ref to the object and either a method or a property that
can change the field.

account.AccountName = "Bla bla";

or:

account.ChangeAccountName("Bla bla");

Arne
 
Back
Top