Когда я запускаю код он дает мне эту ошибку:Как устранить исключение NullReferenceException при использовании двух отдельных классов?
An exception of type 'System.NullReferenceException' occurred in App.dll but was not handled in user code
Additional information: Object reference not set to an instance of an object.
Как бы решить эту проблему?
ExceptionHandling ExManager = new ExceptionHandling();
var Message = ExManager.ExceptionLibrary["10000"]// occured here
класс ExceptionHandling
public class ExceptionHandling
{
private Dictionary<string, string> exceptionlibrary;
public Dictionary<string, string> ExceptionLibrary
{
get { return exceptionlibrary; }
set
{
exceptionlibrary = new Dictionary<string, string>()
{
//User
{"10000", "Invalid user input."},
{"10001", "Phone number is already registered."},
};
}
}
}