using System;
using System.Linq;
namespace Generics1
{
class Program
{
static void Main(string[] args)
{
Rectangle<string> myobj = new Rectangle<string>("8", "6");
Console.WriteLine(myobj.Area());
Console.ReadKey();
}
public struct Rectangle<T>
{
private T length,width;
public T Width { get { return width; } set { width = value; } }
public T Length { get { return length; } set { length = value; } }
public Rectangle(T w, T l)
{
width = w;
length = l;
}
public string Area()
{
double no1=Convert.ToDouble(Width);
double no2=Convert.ToDouble(Length);
return Convert.ToString(no1*no2);
}
}
}
}
using System.Linq;
namespace Generics1
{
class Program
{
static void Main(string[] args)
{
Rectangle<string> myobj = new Rectangle<string>("8", "6");
Console.WriteLine(myobj.Area());
Console.ReadKey();
}
public struct Rectangle<T>
{
private T length,width;
public T Width { get { return width; } set { width = value; } }
public T Length { get { return length; } set { length = value; } }
public Rectangle(T w, T l)
{
width = w;
length = l;
}
public string Area()
{
double no1=Convert.ToDouble(Width);
double no2=Convert.ToDouble(Length);
return Convert.ToString(no1*no2);
}
}
}
}
Comments
Post a Comment