作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
<分区>
假设以下代码(请在最后一节课的代码注释中阅读我的问题):
//This is my Generic Class
public class ClientRequestInfo<K, V>
{
public string Id { get; set; }
private Dictionary<K, V> parameters;
public ClientRequestInfo()
{
parameters = new Dictionary<K, V>();
}
public void Add(K key, V value)
{
parameters.Add(key, value);
}
}
public class ProcessParameters()
{
private void CreateRequestAlpha()
{
ClientRequestInfo<int, string> info = new ClientRequestInfo<int, string>();
info.Add(1, "Hello");
SynchRequest s = new SynchRequest(info);
s.Execute();
}
private void CreateRequestBeta()
{
ClientRequestInfo<int, bool> info = new ClientRequestInfo<int, bool>();
info.Add(1, true);
SynchRequest s = new SynchRequest(info);
s.Execute();
}
}
public class SynchRequest
{
//What type should I put here?
//I could declare the class as SynchRequest<K, V> but I don't want
//To make this class generic.
private ClientRequestInfo<????,?????> info;
private SynchRequest(ClientRequestInfo<?????,?????> requestInfo)
{
//Is this possible?
this.info = requestInfo;
}
public void Execute()
{}
}
我是一名优秀的程序员,十分优秀!