I have the following code:
public static KeyValuePair<string[], string[]> GetAccounts()
{
string[] usernames = { "user1", "user2", "user3" };
string[] oauths = { "oauth1", "oauth2", "oauth3" };
return new KeyValuePair<string[], string[]> (usernames, oauths);
}
And then I am calling the function in Main():
public static void Main(string[] args)
{
KeyValuePair<string[], string[]> users = GetAccounts ();
for (int i = 0; i <= users.Key.Length; i++) {
Console.WriteLine (i);
Console.WriteLine (users.Key.GetValue (i) + " " + users.Value.GetValue (i));
}
}
However, when I get a System.IndexOutOfRangeException on the second console write line. I have no idea why this does not work. I am expecting to see:
user1 oauth1
user2 oauth2
user3 oauth3