にオブジェクトのリストを変換するようタプル配列とオブジェクト定義されたのリストを持っている:私はタプルアレイにList<Tele>
に存在する値を割り当てることにしたいタプル配列
Tuple<string, string, string>[] phone_type
List<Tele> telecomm
public class Tele
{ public string number;
public string displayNumber;
public string type;
}
。以下のコードは動作しません。
obj.phone_type[0] = (Tuple<string,string,string>) obj1.telecommunication[0];
エラーがList
タプル配列にリストの/全ての要素/ sの特定を割り当てるクリーンな方法はあり
Tuple<string,string,string>
に変換することはできません、キャストは冗長であると言います。
することができます代わりに 'Tuple.Create(i.number、i.displayNumber、i.type)'を使用して型引数を 'Tuple'コンストラクタに指定する必要がありません。 – Kyle
@Kyle Good。私は自分の答えを更新しました。 –
@HosseinNarimaniRad。本当にありがとう。これで解決します。 – Mathew