AnatomyOf

Anatomy of a C# file

example.cs
1using System; // and System.Linq, and System.Threading.Tasks, and...
2
3public class Counter
4{
5 private int _total;
6 public void Add(int value) => _total += value;
7
8 static void Main(string[] args)
9 {
10 var counter = new Counter();
11 for (int i = 0; i < 3; i++)
12 counter.Add(i);
13 Console.WriteLine(counter._total);
14 }
15}
C# is a modern, object-oriented, type-safe programming language in the C-family, designed for the .NET platform.