public static SomeStruct?GetSomeStructFromStringValue(object value) { var parsedValue = new SomeStruct(); if ((string)value == parsedValue.ToString()) { return(parsedValue); } throw new FormatException(); }