Click here to Skip to main content
15,884,605 members
Home / Discussions / C#
   

C#

 
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 
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 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Assignment5
{
class Program
{
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"
};

// Create Teacher
Teacher teacher1 = new Teacher
{
TeacherfirstName = "Paul",


};

// Create course object
Course course = new Course();
course.CourseName = "Programming with C#.";

// Create degree object
Degree degree = new Degree();
degree.DegreeName = "Bachelor of Science Degree";

// Create Program object
UProgram uprogram = new UProgram();
uprogram.ProgramName = "Information Technology";

// count = GetActiveInstances(typeof(Student));

Console.WriteLine("The {0} program contains the {1} ", uprogram.ProgramName, degree.DegreeName);
Console.WriteLine("The {0} contains the course {1} ",degree.DegreeName, course.CourseName );
// Console.WriteLine("The {0} course contains students(s)" count);
Console.WriteLine("Count" + Student.count);

Console.Read();
}


public class Student
{
public static int count = 0;
public Student()
{
// Thread safe since this is a static property
Interlocked.Increment(ref count);
}

// use properties!
private string firstName;

// Get Set for FirstName
public string FirstName

{
get { return firstName; }
set { firstName = value; }
}


private string lastName;
// Get Set for LastName
public string LastName
{
get { return lastName; }
set { lastName = value; }
}

private string birthDate;
// Get Set for BirthDate
public string BirthDate
{
get { return birthDate; }
set { birthDate = value; }
}

}


public class Teacher
{

private string teacherfirstName;

public string TeacherfirstName
{
get { return teacherfirstName; }
set { teacherfirstName = value; }
}
// string teacherlastName;
// string teacheroffice;

}

public class UProgram
{
private string programName;

public string ProgramName
{
get { return programName; }
set { programName = value; }
}
// string degreeOffered;
// string department;

}

public class Degree
{
private string courseName;

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


}

public class Course
{
private string courseName;

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


Student[] studentarray = new Student[3];

studentarray[0] = student1;




// studentarray[1] = student2;
// studentarray[2] = student3;

Teacher[] teacherarray = new Teacher[3];
}

}
}
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 
QuestionHow do I add an object to a list within a class? Pin
Doncal18-Apr-15 9:43
Doncal18-Apr-15 9:43 
AnswerRe: How do I add an object to a list within a class? Pin
Pete O'Hanlon18-Apr-15 10:06
mvePete O'Hanlon18-Apr-15 10:06 
AnswerRe: How do I add an object to a list within a class? Pin
Sascha Lefèvre18-Apr-15 10:09
professionalSascha Lefèvre18-Apr-15 10:09 
AnswerRe: How do I add an object to a list within a class? Pin
Doncal18-Apr-15 10:24
Doncal18-Apr-15 10:24 
GeneralRe: How do I add an object to a list within a class? Pin
Sascha Lefèvre18-Apr-15 10:27
professionalSascha Lefèvre18-Apr-15 10:27 
GeneralRe: How do I add an object to a list within a class? Pin
BillWoodruff18-Apr-15 17:28
professionalBillWoodruff18-Apr-15 17:28 
GeneralRe: How do I add an object to a list within a class? Pin
Sascha Lefèvre19-Apr-15 0:44
professionalSascha Lefèvre19-Apr-15 0:44 

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.