33
1
using System;
2
3
public class Student
4
{
5
//class variable
6
public string name {get;set;}
7
public int age {get;set;}
8
9
//class methods
10
public void PrintName()
11
{
12
13
Console.WriteLine("Student name: "+name);
14
Console.WriteLine("Student age: "+age);
15
}
16
}
17
public class Program
18
{
19
public static void Main()
20
{
21
//create Student class object (student)
22
Student student = new Student();
23
24
//assign value to student class variables, using object
25
student.age=15;
26
student.name="John";
27
28
//call student class method using object.
29
student.PrintName();
30
}
31
}
32
33
Cached Result