I’ve got two sets of enum values that are exactly the same but in different namespaces that I want to be able to cast between. How can I do this as I get an object reference not set to an instance of an object
error with my attempt below?
namespace Namespace1
{
public enum RefundResponseEnum
{
AvailableForRefund = 0,
NotAvailable = 1,
MainFrameError = 99
}
}
namespace Namespace1
{
public class Return
{
public Return()
{
}
public RefundResponseEnum Response { get; set; }
}
}
namespace Namespace2
{
public enum RefundResponseEnum
{
AvailableForRefund = 0,
NotAvailable = 1,
MainFrameError = 99
}
}
namespace Namespace2
{
public class Return
{
public Return()
{
}
public RefundResponseEnum Response { get; set; }
}
}
The following below returns an object reference not set to an instance of an object error.
var namespace2Enum = (Namespace2.Return.RefundResponseEnum)((int)Namespace1.Return.Response);
5