Click here to Skip to main content
15,911,141 members
Home / Discussions / C#
   

C#

 
AnswerRe: draw text in richtextbox.. Pin
Christian Graus13-May-08 20:40
protectorChristian Graus13-May-08 20:40 
GeneralRe: draw text in richtextbox.. Pin
kamalesh574313-May-08 21:50
kamalesh574313-May-08 21:50 
GeneralRe: draw text in richtextbox.. Pin
Christian Graus13-May-08 22:27
protectorChristian Graus13-May-08 22:27 
QuestionFull Progressbar within Statusbar Pin
Michael Sync13-May-08 20:17
Michael Sync13-May-08 20:17 
QuestionCreating a Report from XML/Array data in C# Pin
Andy Rama13-May-08 20:15
Andy Rama13-May-08 20:15 
AnswerRe: Creating a Report from XML/Array data in C# Pin
Ashfield13-May-08 21:25
Ashfield13-May-08 21:25 
GeneralRe: Creating a Report from XML/Array data in C# Pin
Andy Rama13-May-08 21:33
Andy Rama13-May-08 21:33 
GeneralRe: Creating a Report from XML/Array data in C# Pin
Andy Rama14-May-08 19:39
Andy Rama14-May-08 19:39 
Questionfisheye image Pin
selvarajanlatha13-May-08 19:18
selvarajanlatha13-May-08 19:18 
AnswerRe: fisheye image Pin
Christian Graus13-May-08 20:10
protectorChristian Graus13-May-08 20:10 
Questionhow can i read a black pixel in binary image and displays it on a test box?? Pin
syarmiza13-May-08 19:03
syarmiza13-May-08 19:03 
AnswerRe: how can i read a black pixel in binary image and displays it on a test box?? Pin
Christian Graus13-May-08 19:04
protectorChristian Graus13-May-08 19:04 
QuestionEvent firing in selectIndexChanged event Pin
steve_rm13-May-08 18:36
steve_rm13-May-08 18:36 
AnswerRe: Event firing in selectIndexChanged event Pin
Christian Graus13-May-08 19:05
protectorChristian Graus13-May-08 19:05 
QuestionGet Member Reference Pin
csharpguy7613-May-08 16:15
csharpguy7613-May-08 16:15 
QuestionDataGridView and Control Box Closing Pin
paas13-May-08 9:07
paas13-May-08 9:07 
QuestionAvoid contextmenustrip pop-up Pin
baranils13-May-08 9:00
baranils13-May-08 9:00 
AnswerRe: Avoid contextmenustrip pop-up Pin
cocoonwls13-May-08 17:38
cocoonwls13-May-08 17:38 
GeneralRe: Avoid contextmenustrip pop-up Pin
baranils13-May-08 19:05
baranils13-May-08 19:05 
GeneralRe: Avoid contextmenustrip pop-up Pin
cocoonwls13-May-08 22:50
cocoonwls13-May-08 22:50 
GeneralRe: Avoid contextmenustrip pop-up Pin
baranils13-May-08 23:01
baranils13-May-08 23:01 
GeneralRe: Avoid contextmenustrip pop-up Pin
cocoonwls14-May-08 15:09
cocoonwls14-May-08 15:09 
GeneralRe: Avoid contextmenustrip pop-up Pin
baranils14-May-08 18:59
baranils14-May-08 18:59 
GeneralRe: Avoid contextmenustrip pop-up Pin
cocoonwls14-May-08 22:14
cocoonwls14-May-08 22:14 
QuestionProblem with C# 3.0 Collection and Object Initializers [modified] Pin
User 665813-May-08 7:58
User 665813-May-08 7:58 
Hi everybody,

I'm feeling a bit dumb here - right now I'm learning some of the nice features of C# 3.0 and can't get this code to compile:

public class Customer
{
   public int Id { get; set; }
   public string Name { get; set; }
   public string City { get; set; }

   public Customer() { }
}

List<Customer> listOfCustomers =
   new List<Customer> {
      { Id = 1, Name="Dave", City="Sarasota" },
      { Id = 2, Name="John", City="Tampa" },
      { Id = 3, Name="Abe", City="Miami" }
   };


Errors are, for each item in the array:

The name 'Id' does not exist in the current context
The name 'City' does not exist in the current context


What's wrong with this code? I've taken the example code from this site[^]

I'm using VS 2008 with .NET 3.5 as target platform.

regards

modified on Tuesday, May 13, 2008 3:11 PM


modified 12-Sep-18 21:01pm.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.