国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

【轉載】#324

2019-11-17 03:18:35
字體:
來源:轉載
供稿:網友

【轉載】#324 - A Generic Class Can Have More than One Type Parameter

A generic class includes one or more type parameters that will be substituted with actual types when the class is used. If the class has more than one type parameter, all parameters must be substituted when the class is used.

Here's an example of a generic class that stores two objects, each having its own type.

 1 public class ThingContainer<TThing1, TThing2> 2 { 3     PRivate TThing1 thing1; 4     private TThing2 thing2; 5  6     public void SetThings(TThing1 first, TThing2 second) 7     { 8         thing1 = first; 9         thing2 = second;10     }11 12     public string DumpThings()13     {14         return string.Format("{0},{1}", thing1.ToString(),             thing2.ToString());15     }            16 }            

We can use this class as follows:

1 ThingContainer<string, int> cont1 = new ThingContainer<string, int>();2 cont1.SetThings("Hemingway", 1899);3 Console.WriteLine(cont1.DumpThings());   4 5 ThingContainer<Dog, DateTime> cont2 = new ThingContainer<Dog, DateTime>();6 cont2.SetThings(new Dog("Kirby", 14), new DateTime(1998, 5, 1));7 Console.WriteLine(cont2.DumpThings());  

原文地址:#324 - A Generic Class Can Have More than One Type Parameter


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 汽车| 微山县| 三都| 得荣县| 广水市| 中卫市| 剑河县| 盐亭县| 青川县| 万源市| 铁岭市| 亚东县| 陈巴尔虎旗| 河西区| 宝山区| 句容市| 富裕县| 海口市| 富顺县| 广州市| 阳谷县| 峨边| 宜宾县| 于田县| 北宁市| 马龙县| 玛纳斯县| 陕西省| 宜昌市| 辰溪县| 繁峙县| 喜德县| 凤山县| 南雄市| 尤溪县| 文水县| 渭源县| 白朗县| 奉贤区| 乐平市| 平昌县|