📦 Math.Sqrt(25) is Verbose. Sqrt(25) is Cleaner.
Using static imports static members. No more Math.Sqrt, Console.WriteLine. Call directly.
❌ Without Using Static
double result = Math.Sqrt(25);
double pi = Math.PI;
string text = string.Concat("Hello", " ", "World");
Console.WriteLine(text);
✅ Using Static
using static System.Math;
using static System.Console;
double result = Sqrt(25);
double pi = PI;
WriteLine(Concat("Hello", " ", "World"));
🎯 Common Use Cases
using static System.Console;
using static System.Math;
using static System.String;
using static System.Environment;
using static System.DateTime;
// Now you can write:
WriteLine("Hello");
double root = Sqrt(16);
bool empty = IsNullOrEmpty(text);
string path = GetFolderPath(SpecialFolder.MyDocuments);
int year = Now.Year;
💡 When to Use
- Math functions (Sqrt, Pow, Sin, Cos, Round)
- Console operations (WriteLine, ReadLine)
- String utilities (Concat, Join, IsNullOrEmpty)
- Environment (GetFolderPath, Exit)
- DateTime (Now, UtcNow, Today)
“Math.Sqrt everywhere was tedious. using static Math; now just Sqrt(). Console.WriteLine became WriteLine(). Code is cleaner, less noise.”
