Originally this was a program with three-parameter constructor (parameter inside the round bracket) and executed well.
Student oneSophomore = new Student(951, "Ross", 3.5);
For curiosity I modified the program and placed the three-parameter inside the curly bracket. After that program is not executing. What corrections have to be done to execute the program.
Student oneSophomore = new Student(){idNumber=951, lastName="Ross", gradePointAverage=3.5};
using System;
public class CreateStudent_byMaha
{
public static void Main()
//Student oneSophomore = new Student(951, "Ross", 3.5);
Console.WriteLine
("The student named {0} has ID # is {1} and a gpa of {2}", oneSophomore.Name, oneSophomore.Id, oneSophomore.GPA);
Console.ReadKey();
}
class Student
private int idNumber;
private string lastName;
private double gradePointAverage;
public Student(int idNumber, string lastName, double gradePointAverage)
this.idNumber = idNumber;
this.lastName = lastName;
this.gradePointAverage = gradePointAverage;
public int Id
get { return idNumber; }
public string Name
get { return lastName; }
public double GPA
get { return gradePointAverage; }
//The student named Ross has ID # is 951 and a gpa of 3.5