Why Tuple's items are ReadOnly?

前端 未结 4 1693
南旧
南旧 2020-12-03 06:30

I was thinking to use Tuple class to store 2 integer information (StartAddress, EndAddress) I need in my program.

But I discover that Tuple

4条回答
  •  無奈伤痛
    2020-12-03 06:51

    You got only the getters of the ItemX properties, that's right, but I found a way to first instanciate a tupple with empty values and fill them afterwords.

    If you do something like this :

    Dictionary > mydic = new  Dictionary>(); 
    Tuple tplTemp = new Tuple("", "");
     mydic.TryGetValue("akey", out tplTemp);
    

    The tplTemp passed as an out parameter will have it's 2 items values from the collection. So that's a way of doing in case this can help's someone.

提交回复
热议问题