C# Generic
* C# Generic :-
1. It is a special type of method accepting random
parameters.
2. Generic is repretesend in angle bracket <>.
3. Generric parameteric is used as Capital T operator.
4. There are two implementation in generic concept.
A. Generic class
B. Generic method
Prog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace proggenericclasss
{
class genericclass<T>
{
public genericclass(T MSG)
{
Console.WriteLine(MSG);
}
}
class Program
{
static void Main(string[] args)
{
//CREATE OBJECT
genericclass<int > s1 = new genericclass<int>(10);
genericclass<string> s2= new genericclass<string>("rahul");
genericclass<double> s3 =new genericclass<double>(154.165);
Console.WriteLine();
Console.ReadKey();
}
}
}
Comments
Post a Comment