What is NullReferenceException in C# and how to fix it?
Hello everyone! I'm a beginner in C# and I keep running into the NullReferenceException error. It occurs in the most unexpected places, and I don't understand what I'm doing wrong. Here's an example of code that crashes for me:\n\n```csharp\npublic class Person\n{\n public string Name;\n public int Age;\n}\n\nclass Program\n{\n static void Main(string[] args)\n {\n Person person = null;\n Console.WriteLine(person.Name); // NullReferenceException occurs here\n }\n}\n```\n\nI just want to print the person's name, but the program crashes. Why does this happen? I've heard it's related to the object being null, but how do I understand this? Maybe I'm creating objects incorrectly? Or do I need to check something before using it? Please advise how to properly work with null in C# and wha