Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

What does "return" do in C#?

public static BankAccount openBankAccount(string owner, double balance, double allowed)

{

BankAccount account;

account = new BankAccount();

account.owner = owner;

account.balance = balance;

account.allowed= allowed;

return account;

}

Update:

Why does it return it? What is the meaning of returning? We don't see anything of it when the program is running. Thank you very much.

2 Answers

Relevance
  • 7 years ago
    Favorite Answer

    The statement "return account" returns the the 'account' object to the method from where the call was made. You can store this 'account' object in another object of 'BankAccount' type and copy the reference of this 'account' in that object for using it in the caller method.

  • 7 years ago

    It returns the instance of BankAccount (account) back to the caller of the method.

Still have questions? Get your answers by asking now.