when to use static methods c# code example
Example 1: c# static meaning
In general, static means “associated with the class, not an instance”.
Example 2: c# public static string
public static string saytest = "test";
private static void Main()
{
Console.WriteLine(saytest);
}
Example 3: what is using static in c#
using System;
using static System.Math;
public class Circle
{
public Circle(double radius)
{
Radius = radius;
}
public double Radius { get; set; }
public double Diameter
{
get { return 2 * Radius; }
}
public double Circumference
{
get { return 2 * Radius * PI; }
}
public double Area
{
get { return PI * Pow(Radius, 2); }
}
}