Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的案例(我得到编译错误,因为 T 未定义):
public void f1(Dictionary<string,T> d){ }
我该如何解决这个问题(我不能传递对象,我必须传递原始的 var 类型)?
(我正在使用.net 4.5)
谢谢
您需要添加类型参数T:
T
public void f1<T>(Dictionary<string,T> d){ }
如果您希望字典包含任何类型的值,那么您唯一的选择是Dictionary<string, object>酌情使用 a 和强制转换。
Dictionary<string, object>
我有一个<table>我想要一个包含其子项的宽度<td>。
<table>
<td>
不幸的是,我只能将类分配给<td>列,而不是<th>列 - 所以我不能table-layout: fixed像往常一样使用。w3 表格布局规范
<th>
table-layout: fixed