diff options
author | Shaun McCarthy <git@shaunmccarthy.com> | 2013-10-26 15:27:53 -0400 |
---|---|---|
committer | Shaun McCarthy <git@shaunmccarthy.com> | 2013-10-26 15:27:53 -0400 |
commit | eccc9e094832350842f16f3a7666aa633748098b (patch) | |
tree | a2bee4a748cd471b30738e5448967f1a9908d59a /csharp.html.markdown | |
parent | 0cee5bd79af4deefe246dde09cdfcd44dca80558 (diff) |
Reanmed to Generics instead of templates
Diffstat (limited to 'csharp.html.markdown')
-rw-r--r-- | csharp.html.markdown | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/csharp.html.markdown b/csharp.html.markdown index f4c30b03..8c15b86f 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -150,7 +150,7 @@ on a new line! ""Wow!"", the masses cried"; List<int> intList = new List<int>(); List<string> stringList = new List<string>(); List<int> z = new List<int> { 9000, 1000, 1337 }; // intialize - // The <> are for templates - Check out the cool stuff section + // The <> are for generics - Check out the cool stuff section // Lists don't default to a value; // A value must be added before accessing the index @@ -369,7 +369,7 @@ on a new line! ""Wow!"", the masses cried"; { } - // TEMPLATES + // GENERICS // The classes for TKey and TValue is specified by the user calling this function. // This method emulates the SetDefault of Python public static TValue SetDefault<TKey, TValue>( @@ -417,12 +417,13 @@ on a new line! ""Wow!"", the masses cried"; var magic = "magic is a string, at compile time, so you still get type safety"; // magic = 9; will not work as magic is a string, not an int - // TEMPLATES + // GENERICS + // var phonebook = new Dictionary<string, string>() { {"Sarah", "212 555 5555"} // Add some entries to the phone book }; - // Calling SETDEFAULT defined as a template above + // Calling SETDEFAULT defined as a generic above Console.WriteLine(SetDefault<string,string>(phonebook, "Shaun", "No Phone")); // No Phone // nb, you don't need to specify the TKey and TValue since they can be // derived implicitly |