Search

Categories

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Send mail to the author(s) E-mail

# Wednesday, June 23, 2010

While trying to figure out what is meant by the 3rd new section in a view in MVC

<%: Html.ActionLink("Edit", "Edit", new { id=item.DinnerID }) %>

So it is really creating an object with a single property id, which is an int, equal to that of the item, which is a Dinner.

image

“Anonymous types provide a convenient way to encapsulate a set of read-only properties into a single object without having to first explicitly define a type”

class Program
{
static void Main(string[] args)
{
// Anonymous types provide a convenient way to encapsulate a set of read-only properties
// into a single object without having to first explicitly define a type
var person = new { Name = "Terry", Age = 21 };
Console.WriteLine("name is " + person.Name);
Console.WriteLine("age is " + person.Age.ToString());

// Anonymous types just get rid of Person1 really.
Person1 person1 = new Person1 { Name = "Bill", Age = 55 };
Console.WriteLine("name is " + person1.Name);
Console.WriteLine("age is " + person1.Age.ToString());
}
}

class Person1
{
public string Name { get; set; }
public int Age { get; set; }
}

Many thanks to the question here for clarifying:
 
All comments require the approval of the site owner before being displayed.
Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview