0% found this document useful (0 votes)
13 views3 pages

Csharpoops& Properties

The document contains multiple C# class implementations demonstrating the creation and manipulation of 'Student' and 'Circle' objects. It showcases various methods for setting and displaying properties, including using constructors, methods, and properties. The examples illustrate basic object-oriented programming concepts such as encapsulation and property access in C#.

Uploaded by

Jyosthna Kumari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Csharpoops& Properties

The document contains multiple C# class implementations demonstrating the creation and manipulation of 'Student' and 'Circle' objects. It showcases various methods for setting and displaying properties, including using constructors, methods, and properties. The examples illustrate basic object-oriented programming concepts such as encapsulation and property access in C#.

Uploaded by

Jyosthna Kumari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

using System;

class Student
{
public int id;
public string name;
public double marks;

}
class Teststudent
{
public static void Main(string[] args)
{
Student o1 = new Student();
[Link] = 101;
[Link] = "Hari";
[Link] = 98.56;
[Link]($"ID: {[Link]}\nName:{[Link]}\nMarks:{[Link]}");

}
}

using System;
class Student
{
public int id;
public string name;
public double marks;
public void display()
{
[Link]($"ID: {id}\nName:{name}\nMarks:{marks}");
}
}
class Teststudent
{
public static void Main(string[] args)
{
Student o1 = new Student();
[Link] = 101;
[Link] = "Hari";
[Link] = 98.56;
[Link]();

}
}

using System;
class Student
{
private int id;
private string name;
private double marks;
public void insert(int i, string n, double m)
{
id = i;
name = n;
marks = m;
}
public void display()
{
[Link]($"ID: {id}\nName:{name}\nMarks:{marks}");
}
}
class Teststudent
{
public static void Main(string[] args)
{
Student o1 = new Student();
[Link](102, "Giri", 87.67);
[Link]();

}
}

using System;
class Student
{
private int id;
private string name;
private double marks;
public void insert(int id, string name, double marks)
{
[Link] = id;
[Link] = name;
[Link] = marks;
}
public void display()
{
[Link]($"ID: {id}\nName:{name}\nMarks:{marks}");
}
}
class Teststudent
{
public static void Main(string[] args)
{
Student o1 = new Student();
[Link](102, "Giri", 87.67);
[Link]();

}
}

using System;
class Student
{
private int id;
private string name;
private double marks;
public Student(int id, string name, double marks)
{
[Link] = id;
[Link] = name;
[Link] = marks;
}
public void display()
{
[Link]($"ID: {id}\nName:{name}\nMarks:{marks}");
}
}
class Teststudent
{
public static void Main(string[] args)
{
Student o1 = new Student(102, "Giri", 87.67);
[Link]();

}
}

Properties:

using System;

class Circle
{
double radius=5.6;
public double CircleProperty
{
get { return radius; }
set { radius = value; }
}
}
class TestCircle
{
public static void Main(string[] args)
{
Circle obj =new Circle();
[Link] = 8.56; // setting property
double rad = [Link]; // getting property
[Link](rad);

}
}

using System;

class Circle
{
double radius=5.6;
public double CircleProperty{get; set;}

}
class TestCircle
{
public static void Main(string[] args)
{
Circle obj =new Circle();
[Link] = 8.56; // setting property
double rad = [Link]; // getting property
[Link](rad);

}
}

You might also like