メソッドの戻り値としてaList<T>
と a の両方を渡す最良の方法は何ですか? bool
現在、コンテナのように振る舞うというカスタムクラスBoolList
がありますが、それを行うためのより良い方法やよりエレガントな方法があるかどうか疑問に思っていました。
質問する
124 次
3 に答える
4
タプルを使用しないのはなぜですか?
http://www.dotnetperls.com/tuple
http://msdn.microsoft.com/en-us/library/dd268536.aspx
次に、クラスを作成しなくても、タイプ セーフなコンテナーを作成できます。
private Tuple<List<int>, bool> myMethod()
{
var myList = new List<int>();
var myBool = true;
return new Tuple<List<int>, bool>(myList, myBool);
}
于 2013-09-11T09:52:16.927 に答える
3
使用できますTuple<List<T>, bool>
public Tuple<List<string>, bool> MethodName()
{
return Tuple.Create(new List<string>(), true);
}
またはList<T>
out
パラメータを作成し、bool
通常のものとして返します(TryParse
メソッドのように)
public bool MethodName(out List<string> results)
{
results = new List<string>();
return true;
}
于 2013-09-11T09:52:52.487 に答える