Question

I am trying to populate Class Member values as follows:

 var myData = new OrdersData(o.symbol)
                        {
                            Account = accountName,

                            Side = (OrderAction) Enum.Parse(typeof(OrderAction),o.side, true) , 

                            Type = o.type, (Cannot convert string to OrderType)                               
                        };

The type mentioned above is of the below type:

public OrderType Type { get; set; }

where OrderType is again derived from:

public struct OrderType
    {
        public OrderType(object Value);

        public bool IsValid { get; }
        public object Value { get; }

        public override string ToString();
    }

So, how do I convert my value (String) to this type (Object)? Anyhelp is greatly appreciated.

Was it helpful?

Solution

Assuming, OrdersData.Type if of OrderType and o.type is string,

var myData = new OrdersData(o.symbol)
{
    Account = accountName,
    Side = (OrderAction) Enum.Parse(typeof(OrderAction),o.side, true), 
    Type = new OrderType(o.type),
};
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top