Patrick Labelle
Patrick's Blog

Follow

Patrick's Blog

Follow
Static vs non-static

Static vs non-static

Patrick Labelle's photo
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