What is NullReferenceException in C# and how to fix it?
Hello everyone! I'm a beginner in C# and constantly encounter the NullReferenceException error. I'm writing a small application for managing an employee list, and when trying to display data about a person, the program crashes with this error. Here's an example code:\n\n```csharp\npublic class Employee\n{\n public string Name;\n public int Age;\n}\n\nclass Program\n{\n static void Main()\n {\n Employee emp = null;\n Console.WriteLine(emp.Name); // Error here!\n }\n}\n```\n\nI understand that the variable `emp` is `null`, but I can't figure out why this happens and how to properly handle such situations. It seems simple: I create an object, but it's empty. How can I avoid this error in the future? Especially when working with collections, databases, or return values from methods.