using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SimpleConstructorPro
{
class Program
{
private double length;
public Program()
{
Console.WriteLine(" Object is being created");
}
public void setLength(double len)
{
length = len;
}
public double getLength()
{
return length;
}
static void Main(string[] args)
{
Program p=new Program();
p.setLength(5.0);
Console.WriteLine(" Length of Program: "+p.getLength());
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SimpleConstructorPro
{
class Program
{
private double length;
public Program()
{
Console.WriteLine(" Object is being created");
}
public void setLength(double len)
{
length = len;
}
public double getLength()
{
return length;
}
static void Main(string[] args)
{
Program p=new Program();
p.setLength(5.0);
Console.WriteLine(" Length of Program: "+p.getLength());
Console.ReadLine();
}
}
}
Output:
No comments:
Post a Comment