1. Variables


int x = 10; // integer variable
double y = 20.5; // floating-point variable
char name = 'A'; // character variable

2. Data Types


int, float, char, double, long, short, unsigned

3. Operators


+, -, \*, /, %, ==, !=, >, <, >=, <=, &&, ||, !

4. Control Structures


if (condition) { code }
if (condition) { code } else { code }
switch (expression) { case value: code; break; }
for (init; condition; increment) { code }
while (condition) { code }
do { code } while (condition);

5. Loops


for (int i = 0; i < 10; i++) { code }
while (i < 10) { code; i++; }
do { code; i++; } while (i < 10);

6. Arrays


int[] scores = {90, 80, 70, 60};
char[] names = {'J', 'o', 'h', 'n'};

7. Methods


int Add(int a, int b) { return a + b; }
void Greet(string name) { Console.WriteLine("Hello, " + name); }

8. Classes


public class Person {
private string name;
public Person(string name) { this.name = name; }
public void Display() { Console.WriteLine("Name: " + name); }
}

9. Objects


Person person = new Person("John Doe");
person.Display(); // prints "Name: John Doe"

10. Inheritance


public class Animal {
public void Sound() { Console.WriteLine("The animal makes a sound."); }
}
public class Dog : Animal {
public void Sound() { Console.WriteLine("The dog barks."); }
}

11. Polymorphism


public class Animal {
public virtual void Sound() { Console.WriteLine("The animal makes a sound."); }
}
public class Dog : Animal {
public override void Sound() { Console.WriteLine("The dog barks."); }
}
Animal animal = new Dog();
animal.Sound(); // prints "The dog barks."

12. Encapsulation


public class Person {
private string name;
public Person(string name) { this.name = name; }
public string GetName() { return name; }
}

13. Abstraction


public abstract class Animal {
public abstract void Sound();
}
public class Dog : Animal {
public override void Sound() { Console.WriteLine("The dog barks."); }
}

14. Interface


public interface IPrintable {
void Print();
}
public class Document : IPrintable {
public void Print() { Console.WriteLine("Printing document..."); }
}

15. Exception Handling


try { code } catch (Exception e) { code }

16. File Input/Output


using System.IO;
File.WriteAllText("example.txt", "Hello, World!");

17. Networking


using System.Net;
using System.Net.Sockets;
TcpClient client = new TcpClient();

18. Multithreading


using System.Threading;
Thread thread = new Thread(new ThreadStart(MyMethod));
thread.Start();

19. Lambda Expressions


Func<int, int> add = x => x + 1;

20. LINQ


using System.Linq;
var numbers = new List<int> { 1, 2, 3, 4 };
var evenNumbers = numbers.Where(n => n % 2 == 0);

21. Nullable Types


int? nullableInt = null;

22. Tuples


var tuple = (1, "Hello");
Console.WriteLine(tuple.Item2); // prints "Hello"

23. String Interpolation


string name = "John";
Console.WriteLine($"Hello, {name}!");

24. String Methods


string str = "Hello, World!";
string upper = str.ToUpper();

25. Collections


List<int> numbers = new List<int> { 1, 2, 3 };
Dictionary<int, string> map = new Dictionary<int, string>();

26. Generics


public class GenericClass<T> {
public T Value { get; set; }
}

27. Attributes


[Obsolete("This method is obsolete.")]
public void OldMethod() { }

28. Properties


public class Person {
public string Name { get; set; }
}

29. Indexers


public class MyCollection {
private int[] array = new int[10];
public int this[int index] {
get { return array[index]; }
set { array[index] = value; }
}
}

30. Events


public event EventHandler MyEvent;
MyEvent?.Invoke(this, EventArgs.Empty);

31. Delegates


public delegate void MyDelegate(string message);

32. Async/Await


public async Task MyMethodAsync() {
await Task.Delay(1000);
}

33. Using Statements


using (var stream = new FileStream("file.txt", FileMode.Open)) { }

34. Extension Methods


public static class MyExtensions {
public static int Square(this int number) { return number * number; }
}

35. Reflection


Type type = typeof(Person);
var properties = type.GetProperties();

36. Dynamic Types


dynamic obj = new ExpandoObject();
obj.Name = "John";

37. Using LINQ with SQL


using (var context = new MyDbContext()) {
var users = context.Users.Where(u => u.IsActive).ToList();
}

38. JSON Serialization


using System.Text.Json;
string json = JsonSerializer.Serialize(myObject);

39. XML Serialization


using System.Xml.Serialization;
XmlSerializer serializer = new XmlSerializer(typeof(MyClass));

40. File Handling


File.WriteAllText("example.txt", "Hello, World!");
string content = File.ReadAllText("example.txt");

41. Console Input/Output


Console.WriteLine("Enter your name:");
string name = Console.ReadLine();

42. StringBuilder


StringBuilder sb = new StringBuilder();
sb.Append("Hello");
sb.Append(" World");

43. HashSet


HashSet<int> set = new HashSet<int> { 1, 2, 3 };

44. SortedSet


SortedSet<int> sortedSet = new SortedSet<int> { 3, 1, 2 };

45. Queue


Queue<int> queue = new Queue<int>();
queue.Enqueue(1);
queue.Enqueue(2);

46. Stack


Stack<int> stack = new Stack<int>();
stack.Push(1);
stack.Push(2);

47. Task Parallel Library


Parallel.For(0, 10, i => { /* code */ });

48. Thread Pool


ThreadPool.QueueUser WorkItem(state => { /* code */ });

49. CancellationToken


CancellationTokenSource cts = new CancellationTokenSource();
CancellationToken token = cts.Token;

50. Task


Task.Run(() => { /* code */ });

51. ValueTuple


var valueTuple = (1, "Hello");
Console.WriteLine(valueTuple.Item2); // prints "Hello"

52. String.Format


string formatted = string.Format("Hello, {0}!", "John");

53. String.Split


string[] parts = "a,b,c".Split(',');

54. String.Join


string result = string.Join(",", new[] { "a", "b", "c" });

55. String.Contains


bool contains = "Hello".Contains("ell");

56. String.IndexOf


int index = "Hello".IndexOf("e");

57. String.Substring


string sub = "Hello".Substring(1, 3); // "ell"

58. String.Replace


string replaced = "Hello".Replace("e", "a");

59. String.Trim


string trimmed = " Hello ".Trim();

60. String.Equals


bool isEqual = "Hello".Equals("hello", StringComparison.OrdinalIgnoreCase);

61. String.Compare


int comparison = string.Compare("a", "b");

62. String.ToCharArray


char[] chars = "Hello".ToCharArray();

63. String.IsNullOrEmpty


bool isNullOrEmpty = string.IsNullOrEmpty(null);

64. String.IsNullOrWhiteSpace


bool isNullOrWhiteSpace = string.IsNullOrWhiteSpace(" ");

65. String.Concat


string concatenated = string.Concat("Hello", " ", "World");

66. StringBuilder.AppendFormat


StringBuilder sb = new StringBuilder();
sb.AppendFormat("Hello, {0}!", "John");

67. String.Join with LINQ


var names = new List<string> { "John", "Jane" };
string result = string.Join(", ", names);

68. Dictionary


Dictionary<int, string> dict = new Dictionary<int, string>();
dict.Add(1, "One");

69. List.Sort


List<int> list = new List<int> { 3, 1, 2 };
list.Sort();

70. List.Reverse


list.Reverse();

71. List.Contains


bool exists = list.Contains(1);

72. List.IndexOf


int index = list.IndexOf(2);

73. List.Remove


list.Remove(1);

74. List.Clear


list.Clear();

75. Dictionary.ContainsKey


bool hasKey = dict.ContainsKey(1);

76. Dictionary.Remove


dict.Remove(1);

77. Dictionary.TryGetValue


if (dict.TryGetValue(1, out string value)) { /* code */ }

78. StringBuilder.Clear


sb.Clear();

79. StringBuilder.Length


int length = sb.Length;

80. StringBuilder.Capacity


int capacity = sb.Capacity;

81. StringBuilder.ToString


string result = sb.ToString();

82. Task.Delay


await Task.Delay(1000);

83. Task.WhenAll


await Task.WhenAll(task1, task2);

84. Task.WhenAny


var completedTask = await Task.WhenAny(task1, task2);

85. CancellationTokenSource.Cancel


cts.Cancel();

86. CancellationToken.ThrowIfCancellationRequested


token.ThrowIfCancellationRequested();

87. Using Statement with IDisposable


using (var resource = new Resource()) { /* code */ }

88. String.IsNullOrEmpty


bool isEmpty = string.IsNullOrEmpty("test");

89. String.IsNullOrWhiteSpace


bool isWhiteSpace = string.IsNullOrWhiteSpace(" ");

90. String.Format with Named Arguments


string formatted = string.Format("Hello, {name}!", new { name = "John" });

91. String.Concat with Multiple Arguments


string concatenated = string.Concat("Hello", " ", "World");

92. StringBuilder.Insert


sb.Insert(0, "Start: ");

93. StringBuilder.Remove


sb.Remove(0, 6); // removes "Start: "

94. StringBuilder.Replace


sb.Replace("World", "C#");

95. StringBuilder.AppendLine


sb.AppendLine("New Line");

96. StringBuilder.AppendFormat


sb.AppendFormat("Value: {0}", 10);

97. String.Join with IEnumerable


var names = new List<string> { "John", "Jane" };
string result = string.Join(", ", names);

98. StringBuilder.Append


sb.Append("Hello");

99. StringBuilder.ToString


string result = sb.ToString();

100. StringBuilder.Capacity


int capacity = sb.Capacity;