December 2018
Beginner to intermediate
668 pages
15h 30m
English
The fields that we have created so far have all been instance members, meaning that a copy of each field exists for each instance of the class that is created.
Sometimes, you want to define a field that only has one copy that is shared across all instances. These are called static members.
In the PacktLibrary project, add a new class named BankAccount. Modify the class, as shown in the following code:
namespace Packt.CS7
{
public class BankAccount
{
public string AccountName;
public decimal Balance;
public static decimal InterestRate;
}
}
In Program.cs and its Main method, add the ...
Read now
Unlock full access