本文介绍了对于函数的单个参数,在传递变量或整个对象时哪个更好的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 为了返回一个List,进行四个不同的函数调用更好或者只有单个函数调用更好 ie I想要一个List<>作为函数的返回类型。 例如列表与LT; T> GetData() 我使用四种不同的重载来获取List< t> as GetData(int a)//这里只需要来自T的x作为返回 GetData(int a,int b)//这里只需要来自T的x和y作为返回 GetData(int a,string c)//这里只需要来自T的y作为返回 GetData(string a)//这里只需要来自T的z返回 我也可以这样做, GetData(Type T) 哪个更好用?将特定变量作为参数或类型作为参数发送?为什么?In order to return a List, making four different functions call is better or only single Function call is betteri.e.I want a List<> as return type from a function.e.g. List<t> GetData()I am using four different overloading to get the List<t> as GetData(int a) //here need only x from T as return GetData(int a, int b) //here need only x and y from T as return GetData(int a, string c) //here need only y from T as return GetData(string a) //here need only z from T as returnAlso I can do like,GetData(Type T)Which is better to use? Sending particular variable as parameter or Type as a parameter? Why?推荐答案 这篇关于对于函数的单个参数,在传递变量或整个对象时哪个更好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-20 19:06