trying to return 2 List values from a single function
I am using this code:-
public KeyValuePair<int, int> encrypt(string password)
{
List<int> key = new List<int>();
List<int> code = new List<int>();
/*
do stuff, do some more stuff and go!
*/
return new KeyValuePair<List<int>,List<int>>(key,code);
}
here I am trying to return 2 List<int>
values but error occurs. How to return 2 list values from a single function
UPDATE
the answer is found, we got 2 correct answers thats why i didn't just pick one cause both work great
answer by HadiRj
answer by Enigmativity
and if you want to use my code then, this is the correct version of it:-
public KeyValuePair<List<int>, List<int>> encrypt(string password)
{
List<int> key = new List<int>();
List<int> code = new List<int>();
/*
do stuff, do some more stuff and go!
*/
return new KeyValuePair<List<int>,List<int>>(key,code);
}
List<>
of pairs, instead of a pair of lists like you have? If so, maybe useList<KeyValuePair<int, int>>
or even simplyDictionary<int, int>
orSortedDictionary<int, int>
. It depends on what data you want to allow. In you solution it is possible to have the count of the keyList<>
either greater or less than the count of the valueList<>
.