如何为此委托分配可变参数

时间:2015-05-01 10:15:38

标签: c# quickfix fix-protocol

尝试使用具有可变数量参数的委托时出现以下错误:

  

错误39使用泛型类型   ' SlotManager.OrdersConnection.delNewOrderSingle'要求   6种类型参数

我做错了什么?

public delegate QuickFix.Message delNewOrderSingle<A,B,C,D,E>(A a, B b, C c, D d, E e);
public delegate QuickFix.Message delNewOrderSingle<A, B, C, D, E, F>(A a, B b, C c, D d, E e, F f);

public virtual QuickFix.Message AgnosticNewOrderSingle42LIMITtest(char side, string symbol, decimal amount, decimal price)
{

            delNewOrderSingle newOrderSingle = new QuickFix.FIX44.NewOrderSingle(
                    new ClOrdID(masterForm.OrderBook.GetNewClOrdIDBroker(ecn.brokerCode)),
                    new Symbol(symbol),
                    new Side(side),
                    new TransactTime(DateTime.Now),
                    ordType = new OrdType(OrdType.LIMIT));


}
  

注意:根据肖恩的评论,我发现问题非常错误。请参阅   这个后续行动

Is it possible to change cast of an object dynamically?

1 个答案:

答案 0 :(得分:1)

您似乎正在尝试将NewOrderSingle的实例分配给代理人。您需要为委托分配方法,而不是对象实例。

此外,由于委托是通用的,您需要指定泛型类型

你的意思是这样做:

delNewOrderSingle<ClOrdID, Symbol, Side, TransactTime, OrdType> newOrderSingle = (a,b,c,d,e) =>  new QuickFix.FIX44.NewOrderSingle(a, b, c, d, e);