Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
C# Dictionary with Enum Keys And Values
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { enum Keys { One = 0, Two = 1, Three = 2 }; enum Values { Foo, Bar, Baz }; public class Program { public static void Main(string[] args) { // --- Create dictionary Dictionary<Keys, Values> dictionary = new Dictionary<Keys, Values>(); // --- Fill in keys and values dictionary.Add(Keys.One, Values.Foo); dictionary.Add(Keys.Two, Values.Bar); dictionary.Add(Keys.Three, Values.Baz); // --- Access some value // 1. direct Console.WriteLine( dictionary[Keys.One] ); // Foo // 2. with index, doesn't work // Console.WriteLine( dictionary[1] ); // Bar // 3. TryGetValue Values value; dictionary.TryGetValue(Keys.Three, out value); Console.WriteLine( value ); // Baz } } }
run
|
edit
|
history
|
help
0
split string
Function Tester
MyProfile_MEDALLA.java
Fórum Parallel Threads ( Without Fun )
Test equality...2
a6
line 1 syntax error
csharp enum
Collatz Conjecture
CryptoJS vs AES