Object Initializer

How would you write the student.Add(new Student() {....} in .net cobol.  My attempt is

invoke student::Add(new Student() (new Student::ID

This is as far as I got before syntax errors.

SqlDataReader dr;
                dr = cmd.ExecuteReader();
                while (dr.Read())
                    student.Add(new Student()
                        ID = dr.GetInt32(dr.GetOrdinal("ID")),
                        Name = dr.GetString(dr.GetOrdinal("Name")),
                        DateOfBirth = dr.GetDateTime(dr.GetOrdinal("DateOfBirth"))
  • Verified Answer

    It's difficult to be sure, as I don't have the whole program context but something like:
    invoke student::Add(new Student(prop ID = dr::GetInt32(...)
    prop Name = ...
    prop DateOfBirth =...))
    You can set properties for the new object like this from within a constructor expression, using keyword 'prop' or 'property'.