Click here to Skip to main content
15,891,529 members
Home / Discussions / C#
   

C#

 
AnswerRe: Retrieving email value from a JSON string \ object. Pin
Doncal19-Apr-15 20:06
Doncal19-Apr-15 20:06 
GeneralRe: Retrieving email value from a JSON string \ object. Pin
Sascha Lefèvre19-Apr-15 21:56
professionalSascha Lefèvre19-Apr-15 21:56 
GeneralRe: Retrieving email value from a JSON string \ object. Pin
Mycroft Holmes19-Apr-15 23:02
professionalMycroft Holmes19-Apr-15 23:02 
GeneralRe: Retrieving email value from a JSON string \ object. Pin
Doncal19-Apr-15 23:40
Doncal19-Apr-15 23:40 
GeneralRe: Retrieving email value from a JSON string \ object. Pin
Sascha Lefèvre20-Apr-15 6:34
professionalSascha Lefèvre20-Apr-15 6:34 
QuestionC# timesheet business logic question Pin
Member 1162043719-Apr-15 12:21
Member 1162043719-Apr-15 12:21 
AnswerRe: C# timesheet business logic question Pin
Sascha Lefèvre19-Apr-15 12:25
professionalSascha Lefèvre19-Apr-15 12:25 
QuestionHow do I add 3 objects to array in C# Pin
Aindriu Mac Giolla Eoin19-Apr-15 8:27
Aindriu Mac Giolla Eoin19-Apr-15 8:27 
Hi,

How can I add 3 objects to an array in C# ? I created 3 objects of a class and I want those three objects in an array in another class but I get the syntax wrong.

here in the main method I created 3 objects from Class student

C#
static void Main(string[] args)
        {

         //  Create 3 students
            Student student1 = new Student

            {
                FirstName = "John",
                LastName = "Wayne",
                BirthDate = "26/05/1907"

            };

            Student student2 = new Student
            {
                FirstName = "Craig",
                LastName = "Playstead",
                BirthDate ="01/01/1967"
            };

            Student student3 = new Student
            {
                FirstName = "Paula",
                LastName = "Smith",
                BirthDate = "01/12/1977"
            };


In another class I want to create an array and put the 3 student objects into it, how do I do that ? So far I only created an array[3]

C#
Public class Course
        {
            private string courseName;

            public string CourseName
            {
                get { return courseName; }
                set { courseName = value; }
            }


            Student[] studentarray = new Student[3];


modified 19-Apr-15 14:35pm.

AnswerRe: How do I add 3 objects to array in C# Pin
Sascha Lefèvre19-Apr-15 8:31
professionalSascha Lefèvre19-Apr-15 8:31 
GeneralRe: How do I add 3 objects to array in C# Pin
Aindriu Mac Giolla Eoin19-Apr-15 8:33
Aindriu Mac Giolla Eoin19-Apr-15 8:33 
GeneralRe: How do I add 3 objects to array in C# Pin
Sascha Lefèvre19-Apr-15 8:38
professionalSascha Lefèvre19-Apr-15 8:38 
GeneralRe: How do I add 3 objects to array in C# Pin
Aindriu Mac Giolla Eoin19-Apr-15 8:44
Aindriu Mac Giolla Eoin19-Apr-15 8:44 
GeneralRe: How do I add 3 objects to array in C# Pin
PIEBALDconsult19-Apr-15 9:01
mvePIEBALDconsult19-Apr-15 9:01 
GeneralRe: How do I add 3 objects to array in C# Pin
Sascha Lefèvre19-Apr-15 9:03
professionalSascha Lefèvre19-Apr-15 9:03 
GeneralRe: How do I add 3 objects to array in C# Pin
Aindriu Mac Giolla Eoin19-Apr-15 9:13
Aindriu Mac Giolla Eoin19-Apr-15 9:13 
GeneralRe: How do I add 3 objects to array in C# Pin
Sascha Lefèvre19-Apr-15 9:16
professionalSascha Lefèvre19-Apr-15 9:16 
GeneralRe: How do I add 3 objects to array in C# Pin
Aindriu Mac Giolla Eoin19-Apr-15 9:24
Aindriu Mac Giolla Eoin19-Apr-15 9:24 
GeneralRe: How do I add 3 objects to array in C# Pin
Sascha Lefèvre19-Apr-15 9:27
professionalSascha Lefèvre19-Apr-15 9:27 
GeneralRe: How do I add 3 objects to array in C# Pin
Aindriu Mac Giolla Eoin19-Apr-15 9:32
Aindriu Mac Giolla Eoin19-Apr-15 9:32 
QuestionGoogle Spreadsheets API - Getting Data into dataGridView? Pin
Linus Agren19-Apr-15 6:00
Linus Agren19-Apr-15 6:00 
AnswerRe: Google Spreadsheets API - Getting Data into dataGridView? Pin
Linus Agren20-Apr-15 18:04
Linus Agren20-Apr-15 18:04 
QuestionCatch Win+Left (Aero-Snap)? Pin
SledgeHammer0118-Apr-15 16:01
SledgeHammer0118-Apr-15 16:01 
AnswerRe: Catch Win+Left (Aero-Snap)? Pin
Dave Kreskowiak18-Apr-15 18:47
mveDave Kreskowiak18-Apr-15 18:47 
GeneralRe: Catch Win+Left (Aero-Snap)? Pin
SledgeHammer0118-Apr-15 20:19
SledgeHammer0118-Apr-15 20:19 
SuggestionRe: Catch Win+Left (Aero-Snap)? Pin
Richard Deeming20-Apr-15 2:34
mveRichard Deeming20-Apr-15 2:34 

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.