how can I validate user input in my method with my interface, where all allowed inputs are stored? if I do so then I get System.NullReferenceException:
public interface INumbUnit
{
public string UnitName { get; set; }
}
public void ValidateNumb()
{
INumbUnit? x = null;
while (string.IsNullOrEmpty(UserSourceUnit))
{
Console.WriteLine("[ERROR] Input can't be empty! Please try again.");
ChooseUnits();
}
while(UserSourceUnit != x.UnitName) //0Reference
{
Console.WriteLine("[ERROR] No such unit for selection! Please try again.");
}
}
UserSourceUnit is just a Console.ReadLine
UnitNames are stored in extern classes but there is still a reference to them, so I don't think that's the problem