anonymous types - c#, what does method ( new { x=y.property } ) mean? -


i've been watching videos on asp.net mvc, think question general c# 1 though.

i notice in example code, method paramters called this

blah.method("something here",             "something else",             new { blah=item.someproperty }); 

can explain happening 3rd parameter? see video watching, method takes in object third paramter.

it anonymous type, property called blah, given value evaluating item.someproperty. in cases interesting way of passing set of key/value pairs - easier dictionary, example:

new {forename="fred", surname="jones" } 

is simpler same dictionary , 2 records ("forename"/"fred", "surname"/"jones"). mvc uses approach in number of places pass in semi-optional parameters (a bit convention on configuration). quite comparable lot of jquery, , let's face it: mvc users using jquery, 2 approaches site quite nicely together.

i discuss topic (along string.format example so) on blog, here: pass data simply; learning jquery , asp.net mvc.


Comments

Popular posts from this blog

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -

openssl - Load PKCS#8 binary key into Ruby -