Static Keyword: Instantiation, Usage, and Best Practices

Understanding Static Keyword

Static is a keyword that makes it instantiate only once internal when the static class is consumed first.

Instantiating Classes

In the class without static, we have to instantiate to use, but we can instantiate many times and store different data on each instance.

 

This is the customer class that gets the customer's information.

Using Static and Non-Static methods

We will move the System.Environment.MachineName; to a different class and use with static and without static to see the difference.

 

namespace BasicCsharp
{
    public class CompName
    {
        public string getName()
        {
            return System.Environment.MachineName;
        }
    }
}

 

GE HealthCare will never ask for payment to process documents, refer you to a third party to process