25. parameterized_constructor in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace parameterized_constructor.cs
{
class prcon
{
int a, b;
public prcon(int a, int b)
{
this.a = a;
this.b = b;
}
public void add()
{
int c;
c = a + b;
Console.WriteLine("Addition = " + c);
}
}
class Program
{
static void Main(string[] args)
{
prcon obj = new prcon(10, 20);
obj.add();
Console.Read();
}
}
}
OUTPUT:
Addition = 30
Comments
Post a Comment