Patrick Labelle
Patrick's Blog

Patrick's Blog

Static vs non-static

Static vs non-static

Patrick Labelle
·Feb 12, 2021·

Static would mean that you don't need an object in order to call the property or method, all you would need to do is call the method/property directly.

An example of this would be as follows:

class Account
{
private static double interestRate;
private double balance;
public static double GetInterestRate()
{
          return interestRate;
}
public double GetBalance()
{
          return balance;
}
}

by calling it with Console.WriteLine(Account.GetInterestRate());

In comparison of having to create the object initially.

Account myAccount = new Account();
Console.WriteLine(myAccount.GetInterestRate());
 
Share this