Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
generics
kamal
Sep 16 2010 4:01 PM
2.3k
Reply
how to add two integer and float variables?
class genericclass<T>
{
private T a;
private T b;
public void sum(T val1, T val2)
{
Console.WriteLine(" sum is "+ (val1 + val2));
}
}
class Program
{
static void Main(string[] args)
{
genericclass<int> gcint1= new genericclass<int>;
gcint1.sum(2, 3);
genericclass<float> gcfloat1=new genericclass<float>;
gcfloat1.sum(2.0, 3.0);
}
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
How to create Web scraper with login
The problem with sending mail