Click here to Skip to main content
15,891,033 members
Home / Discussions / C#
   

C#

 
Questionc# literal conversion Pin
Chris Rickard20-Jul-07 9:33
Chris Rickard20-Jul-07 9:33 
AnswerRe: c# literal conversion Pin
Luc Pattyn20-Jul-07 17:45
sitebuilderLuc Pattyn20-Jul-07 17:45 
GeneralRe: c# literal conversion Pin
Chris Rickard20-Jul-07 18:07
Chris Rickard20-Jul-07 18:07 
GeneralRe: c# literal conversion Pin
Luc Pattyn20-Jul-07 18:21
sitebuilderLuc Pattyn20-Jul-07 18:21 
GeneralRe: c# literal conversion Pin
Chris Rickard20-Jul-07 18:32
Chris Rickard20-Jul-07 18:32 
QuestionRetrieve build-configuration in VS2003 Pin
AlexZieg7120-Jul-07 9:23
AlexZieg7120-Jul-07 9:23 
AnswerRe: Retrieve build-configuration in VS2003 Pin
Dave Kreskowiak20-Jul-07 9:55
mveDave Kreskowiak20-Jul-07 9:55 
QuestionMethods with generic value type parameters in C# [modified] Pin
gshen20-Jul-07 8:18
gshen20-Jul-07 8:18 
Friends:

I defined a method with a generic value type parameter as follows, but it does not compile (Operator '-' cannot be applied to operands of type 'T' and 'T'; Operator '>' cannot be applied to operands of type 'T' and 'T').
//Declaration
public class Algos
{
public bool CompValues <t> (T t1, T t2) //the generic sign after CompValues was deleted automatically by the website
{
T dif;
dif = t1 - t2;
if(dif > t1)
return true;
else
return false;
}
}
//Calling
Algos al = new Algos();
al.CompValues<int>(5, 3); //the generic sign enclosing "int" after CompValues was deleted automatically by the website

Whether I add constraints or not :"where T: struct" and/or "where T: IComparable<t>", it does not compile. Why?

Thanks!









-- modified at 14:30 Friday 20th July, 2007

Sheng

AnswerRe: Methods with generic value type parameters in C# Pin
Kevin McFarlane20-Jul-07 8:38
Kevin McFarlane20-Jul-07 8:38 
GeneralRe: Methods with generic value type parameters in C# Pin
gshen20-Jul-07 8:47
gshen20-Jul-07 8:47 
GeneralRe: Methods with generic value type parameters in C# Pin
Dave Kreskowiak20-Jul-07 9:01
mveDave Kreskowiak20-Jul-07 9:01 
GeneralRe: Methods with generic value type parameters in C# Pin
Kevin McFarlane20-Jul-07 9:02
Kevin McFarlane20-Jul-07 9:02 
GeneralRe: Methods with generic value type parameters in C# Pin
gshen20-Jul-07 9:10
gshen20-Jul-07 9:10 
GeneralRe: Methods with generic value type parameters in C# Pin
Dave Kreskowiak20-Jul-07 9:51
mveDave Kreskowiak20-Jul-07 9:51 
GeneralRe: Methods with generic value type parameters in C# Pin
Larantz21-Jul-07 9:51
Larantz21-Jul-07 9:51 
GeneralRe: Methods with generic value type parameters in C# Pin
Dave Kreskowiak22-Jul-07 4:21
mveDave Kreskowiak22-Jul-07 4:21 
QuestionDetecting when multiple BackgroundWorkers are finished Pin
dilucidate20-Jul-07 8:05
dilucidate20-Jul-07 8:05 
AnswerRe: Detecting when multiple BackgroundWorkers are finished Pin
led mike20-Jul-07 8:23
led mike20-Jul-07 8:23 
GeneralRe: Detecting when multiple BackgroundWorkers are finished Pin
dilucidate20-Jul-07 8:48
dilucidate20-Jul-07 8:48 
GeneralRe: Detecting when multiple BackgroundWorkers are finished Pin
led mike23-Jul-07 5:02
led mike23-Jul-07 5:02 
QuestionFocusable Panel Pin
Sukhjinder_K20-Jul-07 7:14
Sukhjinder_K20-Jul-07 7:14 
AnswerRe: Focusable Panel Pin
Judah Gabriel Himango20-Jul-07 7:29
sponsorJudah Gabriel Himango20-Jul-07 7:29 
GeneralRe: Focusable Panel Pin
Sukhjinder_K20-Jul-07 7:39
Sukhjinder_K20-Jul-07 7:39 
QuestionSerialization of arrays Pin
Rudolf Jan20-Jul-07 7:05
Rudolf Jan20-Jul-07 7:05 
AnswerRe: Serialization of arrays Pin
led mike20-Jul-07 7:14
led mike20-Jul-07 7:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.