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 |
Write a program in c# to find the angle between the hours and minutes in a clock?
Can a loop recorder detect a heart attack?
how can we pass parameters to a user control using delegates ?
What is interface c#?
What are c# types?
Is boxing an implicit conversion?
Explain more on CLR
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.
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#?
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?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)