日期:2014-05-17  浏览次数:20813 次

请问如何在自定义函数中返回两个值?
请问如何在自定义函数中返回两个值,一个是int型,一个是 List<string>型。C#是否有结构体,能否通过结构体实现,请给出示范代码,谢谢


------解决方案--------------------
C# code

class YourClass
{
int Num;
List<string> Items
}


private YourClass Foo()
{
YourClass yc = new YourClass();
yc.Num = 0;
yc.Items = new List<string>();
yc.Items.Add("abc");
return yc;
}

------解决方案--------------------
第一种:

private List<T> Get(out int)
{}


第二种:

struct Test<T>
{
int A {get;set;}
List<T> List {get;set;}
}


private Test<T> Get()
{}