Use of Float in Generic C#

In this article I will describe float data type use with generic C#.
  • 8638

Introduction

Generic is the greatest concept of C# in .net. Generic is a class, when we make program of generic then we use this bracket < > such as temp<T> where T is the user define class . That class hold the user define data type or encapsulate the feature of data type. Generic is type safe template implementation of .net. and generic is also called the template class.

Example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class temp<T>
{   
T _value;
private
double p;
public
temp(T t)
{
this._value=t;
}
public temp()
{
 // TODO: Complete member initialization
}
public
temp(double p)
{
// TODO: Complete member initialization
this.p = p;
}
public
void write()
{
Console
.WriteLine(this._value);
}
}
class Prog
{
static void Main()
{
temp<float> temp1=new temp<float>(5.7f);
temp1.write();
Console.ReadLine();
}
}

Output

aa.jpg

© 2020 DotNetHeaven. All rights reserved.