Practical 10: NAME - Aman Garg ROLL NO - 1/17/FET/BCC/015
Practical 10: NAME - Aman Garg ROLL NO - 1/17/FET/BCC/015
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication193
{
class Program
{
static void Main(string[] args)
{
StringBuilder sb = new StringBuilder("This book");
string s = "is completed";
Console.WriteLine("Length of the stringbuilder {0} is {1}", sb, sb.Length);
Console.WriteLine("Capacity of the stringbuilder {0} is {1}", sb,
sb.Capacity);
Console.WriteLine("StringBuilder before appending is {0}", sb);
Console.WriteLine("StringBuilder after appending {0} is {1}", s,
sb.Append(s));
Console.WriteLine("stringbuilder after inserting now is {0}", sb.Insert(11,
"now"));
Console.WriteLine("StringBuilder after removing 'is' is {0}", sb.Remove(8,
3));
Console.WriteLine("Stringbuilder replacing all 'o' with 'x' is {0}",
sb.Replace('o', 'x'));
Console.ReadLine();
}
}
}
S
PRACTICAL 11
NAME – Aman Garg
ROLL NO – 1/17/FET/BCC/015
AIM: WAP TO SHOW CONSTRUCTOR OVERLOADING
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication193
{
class GameScore
{
string user;
int age;
//Default Constructor
public GameScore()
{
user = "Steven";
age = 28;
Console.WriteLine("Previous User {0} and he was {1} year old", user, age);
}
//Parameterized Constructor
public GameScore(string name, int age1)
{
user = name;
age = age1;
Console.WriteLine("Current User {0} and he is {1} year old", user, age);
}
}
class Program
{
static void Main(string[] args)
{
GameScore gs = new GameScore(); //Default Constructor Called
GameScore gs1 = new GameScore("Clark", 35); //Overloaded Constructor.
Console.ReadLine();
}
}
}
OUTPUT
PRACTICAL 12
NAME – Aman Garg
ROLL NO – 1/17/FET/BCC/015
AIM: WAP TO IMPLEMENT THE PROPERTIES IN C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication193
{
// C# program to illustrate the
// read and wirte property
public class Student
{
// Declare name field
private string name = "GeeksforGeeks";
// Declare name property
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
}
class TestStudent
{
// Main Method
public static void Main(string[] args)
{
Student s = new Student();