有个类的方法:
void Call<T>(string command, Responder<T> responder, params object[] arguments);
Responder<T> responder 这个该如何赋值? 没怎么用过c#,麻烦指点下,谢谢。
Responder类代码如下:public delegate void ResultFunction<T>(T @object);
    /// <summary>
    /// The function invoked if the server returns an error.
    /// </summary>
    public delegate void StatusFunction(Fault fault);    /// <summary>
    /// The Responder class provides an object that is used in NetConnection.call() to handle return values from the server related to the success or failure of specific operations. 
    /// When working with NetConnection.call(), you may encounter a network operation fault specific to the current operation or a fault related to the current connection status. 
    /// Operation errors target the Responder object instead of the NetConnection object for easier error handling.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class Responder<T>
    {
        private readonly ResultFunction<T> _result;
        private readonly StatusFunction _status;        /// <summary>
        /// Initializes a new instance of the <see cref="Responder&lt;T&gt;"/> class.
        /// You pass a Responder object to NetConnection.call() to handle return values from the server. You may pass null for either or both parameters.
        /// </summary>
        /// <param name="result">The function invoked if the call to the server succeeds and returns a result.</param>
        public Responder(ResultFunction<T> result)
            : this(result, null)
        {
        }        /// <summary>
        /// Initializes a new instance of the <see cref="Responder&lt;T&gt;"/> class.
        /// You pass a Responder object to NetConnection.call() to handle return values from the server. You may pass null for either or both parameters.
        /// </summary>
        /// <param name="result">The function invoked if the call to the server succeeds and returns a result.</param>
        /// <param name="status">The function invoked if the server returns an error.</param>
        public Responder(ResultFunction<T> result, StatusFunction status)
        {
            _result = result;
            _status = status;
        }        /// <summary>
        /// Gets the function invoked if the call to the server succeeds and returns a result.
        /// </summary>
        /// <value>The result function.</value>
        public ResultFunction<T> Result
        {
            get { return _result; }
        }        /// <summary>
        /// Gets the function invoked if the server returns an error.
        /// </summary>
        /// <value>The status function.</value>
        public StatusFunction Status
        {
            get { return _status; }
        }
    }

解决方案 »

  1.   

    比如你的返回值类型是string
    Responder<string> responder = new Responder<string>(CallBack);
    void CallBack(Fault fault)
    {
       ...
    }
      

  2.   

    Responder<string> responder = new Responder<string>(new ResultFunction(CallBack));
      

  3.   

    利用重载的两个构造函数
    public Responder(ResultFunction<T> result)
                : this(result, null)
            {
            }public Responder(ResultFunction<T> result, StatusFunction status)
            {
                _result = result;
                _status = status;
            }
      

  4.   


    谢谢。我改为:
    Responder<object> responder = new Responder<object>(new ResultFunction<object>(CallBack));
    编译提示:
    错误 1 “CallBack”的重载均与委托“FluorineFx.Net.ResultFunction<object>”不匹配
      

  5.   

    你把callback的参数改为和 ResultFunction<T> 一样的参数就行了。