Oop Prac
Oop Prac
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication4
public Form1()
InitializeComponent();
if(!File.Exists(f)){
File.Create(f).Close();
}
write.WriteLine(textBox1.Text);
string line;
listBox1.Items.Add(line);
}
QUESTION 2
2a)
using System;
using System.Linq;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] numbers = {10,20,30,40,50,60,70,80,90,100};
Console.WriteLine("Array: " + string.Join(",", numbers));
// Rectangle class
public class Rectangle : Shape
{
public double Width { get; set; }
public double Height { get; set; }
// Square class
public class Square : Rectangle
{
public Square(double sideLength) : base(sideLength, sideLength)
{
}
}
// Circle class
public class Circle : Shape
{
public double Radius { get; set; }
class Program
{
static void Main()
{
Rectangle rectangle = new Rectangle(4, 5);
Console.WriteLine("Rectangle Area: " + rectangle.CalculateArea() );
Console.WriteLine("Rectangle Perimeter:
"+rectangle.CalculatePerimeter());
QUESTION 5
a)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
static void Main()
{
try
{
Console.Write("Enter first number: ");
int a = int.Parse(Console.ReadLine());
Console.Write("Enter second number: ");
int b = int.Parse(Console.ReadLine());
}
}