1 using System; // help me to write this code in object oriented

3 namespace ConsAppl_OOP_Keo_c39
4 {
5 class Procedure_Orieted_Programming
6 {
7 static void Registration(string studentID, string courseNumber)
8 {
9 Console.WriteLine("Данныерегист-циистуд-та: №студента - " + studentID + ", №курса - " + courseNumber);

10 }
11 static void Main()
12 {
13 string studentID = "13", courseNumber = "7";
14 Registration(studentID, courseNumber);
15 Console.ReadLine();
16 }
17 }
18 }

First you create your class, within your class you put your properties and methods so a class for the student will look like this.

public class Student 
{
   private string studentId;
   public string StudentId
   {
      get { return studentId; }
      set { studentId = value; }
   }
   private string courseId;
   public string CourseId
   {
      get { return courseId; }
      set { courseId = value; }
   }
   public void Registration()
   {
      Console.WriteLine(this.studentId + " - " + this.courseId);
   }
}

and then and your main function you can instantiate an object student like this

Student student = new Student();
student.StudentId = "1";
student.CourseId = "2";
student.Registration();
commented: Well explained +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.