class Program { static void Main(string[] args) { AnyClass objAnyClas = null; objAnyClas.AnyProperty = 25; // Object reference error raises , since the object is null objAnyClas.AnyMethod(); // Object reference error raises , since the object is null // to avoid the error you can check for null values of the object if (objAnyClas != null) { objAnyClas.AnyMethod(); var some = objAnyClas.AnyProperty; } } class AnyClass { public int AnyProperty { get; set; } public void AnyMethod() { } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)