Last active
August 24, 2021 12:05
-
-
Save musoftware/889b248224ef1906f1504a178e7cb37d to your computer and use it in GitHub Desktop.
make Dict
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace test | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
MakeDict(new int[] { 10, 20, 30 }, new string[] { "B1", "B2", "B3" }); | |
} | |
static Dictionary<int, string> MakeDict(int[] keys, string[] values) | |
{ | |
if (keys.Length != values.Length) return null; | |
var dict = new Dictionary<int, string>(); | |
for (int i = 0; i < keys.Length; i++) | |
{ | |
dict.Add(keys[i], values[i]); | |
Console.WriteLine("{0} -> {1}", keys[i], values[i]); | |
} | |
return dict; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment