c# - Shortcuts for overly terse generic types -


i'd pass parameter of dictionary method.

public static void method(dictionary<string, string> hash) 

i'd use inline collection initializer

this not legal

method({{"foo", "bar"}, {"bing", "bong"}}) 

neither this

method(new {{"foo", "bar"}, {"bing", "bong"}}) 

this is

// outside class     using d = system.collections.generic.dictionary<string, string>; // calling type alias method(new d {{"foo", "bar"}, {"bing", "bong"}}) 

so this

// once in library somewhere class sd : system.collections.generic.dictionary<string, string> {} // calling class method(new sd {{"foo", "bar"}, {"bing", "bong"}}) 

do have shortcut i'm not aware of solving type collection initialization?

no, can't declare dictionary way you're wanting. in c#6, there prettier dictionary initializer syntax, it's not want:

using d = system.collections.generic.dictionary<string, string>;  //...  method(new d { ["foo"] = "bar", ["bing"] = "bong" }); 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -