C#泛型对类型参数的推断
生活随笔
收集整理的這篇文章主要介紹了
C#泛型对类型参数的推断
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace 泛型對類型參數的推斷 {class Program{public static void genericMtthod<T>( T t1, T t2){T temp = t1;t1 = t2;t2 = temp;}static void Main(string[] args){int a = 1, b = 2;genericMtthod( a, b);Console.WriteLine("a:" + a);Console.WriteLine("b:" + b);string c="c",d="d";genericMtthod( c, d);Console.WriteLine("c:" + c);Console.WriteLine("d:" + d);Console.ReadKey();}} }運行效果圖:
?
轉載于:https://www.cnblogs.com/xiefengdaxia123/p/5983035.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的C#泛型对类型参数的推断的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Edit Distance编辑距离(NM
- 下一篇: Unix command to find