Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How do you restrict the type which can be used in custom
generic?



How do you restrict the type which can be used in custom generic?..

Answer / kishore.a

To restrict a type in Generic just specify the constraint
immediately following the method header, prior to the curly
braces of the method block:

For EX: you can restrict a type parameter to implement
IComparable

public class ConsoleTreeControl
{
// Generic method Show<T>
public static void Show<T>(BinaryTree<T> tree, int indent)
where T : IComparable
{
//Your Code

}
}

So this cannot implement IComparable interface.

Is This Answer Correct ?    6 Yes 2 No

Post New Answer

More C Sharp Interview Questions

Write a program in c# to find the angle between the hours and minutes in a clock?

0 Answers  


Can a loop recorder detect a heart attack?

0 Answers  


how can we pass parameters to a user control using delegates ?

1 Answers   IBM,


What is interface c#?

0 Answers  


What are c# types?

0 Answers  


Is boxing an implicit conversion?

0 Answers  


Explain more on CLR

0 Answers  


How do you create multiple inheritance in C#?

5 Answers   Infosys, KenIndia, Microsoft,


how to compare numbers and dispaly the largest ? *first thing I wanted to do is to input how many numbers to be compared *and then analyzed the largest then display it.

0 Answers  


Is it possible to add two 50 digit numbers in .net? If yes what is the code snippet?

2 Answers   Cognizant, W3 Solutions, Zefer,


Explain how do I convert a string to an int in c#?

0 Answers  


State whether it is true to test a Web service you must create a windows application or Web application to consume this service or not?

0 Answers   Siebel,


Categories