Click here to Skip to main content
15,918,967 members
Home / Discussions / C#
   

C#

 
GeneralRe: Capturing every minimize and restore [modified] Pin
Spacix One4-Sep-07 7:48
Spacix One4-Sep-07 7:48 
GeneralRe: Capturing every minimize and restore Pin
Skippums4-Sep-07 12:05
Skippums4-Sep-07 12:05 
GeneralRe: Capturing every minimize and restore Pin
Spacix One4-Sep-07 14:19
Spacix One4-Sep-07 14:19 
AnswerRe: Capturing every minimize and restore Pin
Spacix One6-Sep-07 5:14
Spacix One6-Sep-07 5:14 
GeneralRe: Capturing every minimize and restore Pin
Giorgi Dalakishvili6-Sep-07 5:36
mentorGiorgi Dalakishvili6-Sep-07 5:36 
GeneralRe: Capturing every minimize and restore Pin
Spacix One6-Sep-07 6:52
Spacix One6-Sep-07 6:52 
QuestionFailed to import C++ COM DLL in to C# in .NET 2005 Pin
Jack Rong4-Sep-07 5:48
Jack Rong4-Sep-07 5:48 
QuestionPassing IP from client across servers Pin
Gump6194-Sep-07 5:38
Gump6194-Sep-07 5:38 
Questionhow to get a list of all avilable controls in a namespace Pin
Amar Chaudhary4-Sep-07 5:21
Amar Chaudhary4-Sep-07 5:21 
AnswerRe: how to get a list of all avilable controls in a namespace Pin
led mike4-Sep-07 5:39
led mike4-Sep-07 5:39 
QuestionRe: how to get a list of all avilable controls in a namespace Pin
Amar Chaudhary4-Sep-07 6:55
Amar Chaudhary4-Sep-07 6:55 
AnswerRe: how to get a list of all avilable controls in a namespace Pin
Amar Chaudhary4-Sep-07 7:00
Amar Chaudhary4-Sep-07 7:00 
GeneralRe: how to get a list of all avilable controls in a namespace Pin
Giorgi Dalakishvili4-Sep-07 7:18
mentorGiorgi Dalakishvili4-Sep-07 7:18 
GeneralRe: how to get a list of all avilable controls in a namespace Pin
led mike4-Sep-07 7:28
led mike4-Sep-07 7:28 
GeneralRe: how to get a list of all avilable controls in a namespace Pin
Amar Chaudhary4-Sep-07 19:44
Amar Chaudhary4-Sep-07 19:44 
QuestionRegEx help for a RegEx Newb Pin
flipdoubt4-Sep-07 5:04
flipdoubt4-Sep-07 5:04 
AnswerRe: RegEx help for a RegEx Newb Pin
Christian Graus4-Sep-07 5:11
protectorChristian Graus4-Sep-07 5:11 
GeneralRe: RegEx help for a RegEx Newb Pin
flipdoubt4-Sep-07 5:14
flipdoubt4-Sep-07 5:14 
GeneralRe: RegEx help for a RegEx Newb Pin
Christian Graus4-Sep-07 6:04
protectorChristian Graus4-Sep-07 6:04 
AnswerRe: RegEx help for a RegEx Newb Pin
Joseph Guadagno4-Sep-07 5:14
Joseph Guadagno4-Sep-07 5:14 
GeneralRe: RegEx help for a RegEx Newb Pin
DavidNohejl4-Sep-07 6:03
DavidNohejl4-Sep-07 6:03 
AnswerRe: RegEx help for a RegEx Newb Pin
ednrgc4-Sep-07 5:38
ednrgc4-Sep-07 5:38 
AnswerRe: RegEx help for a RegEx Newb Pin
Skippums4-Sep-07 12:12
Skippums4-Sep-07 12:12 
QuestionC# Generics - Using operators with generic objects Pin
funkymint4-Sep-07 4:28
funkymint4-Sep-07 4:28 
I have the following function:

public bool getOperatorResult<T>(string operatorType, T operandA, T operandB)
        {
            //If the operands are boolean values.
            if (typeof(T) == typeof(bool))
            {
                System.Object obj = operandA;
                bool a = (bool) obj;
                obj = operandB;
                bool b = (bool) obj;
                switch (operatorType)
                {
                    case "or":
                        return (a || b);
                    case "and":
                        return (a && b);
                    case "equal":
                        return (a == b);
                    case "notequal":
                        return (a != b);
                    default:
                        return false;
                }
            }
            //If the operands are number values.
            else if ((typeof(T) == typeof(int)) || (typeof(T) == typeof(double)))
            {
                //Do something similar but for both int and double
            }
        }


This code works but just does not look right to me. Also in the second part where I look for numbers, I don't know how I can cast to either int or double. Any ideas

If I try to directly put in:

switch (operatorType)
                {
                    case "lessthan":
                        return (operandA < operandB);
                    case "morethan":
                        return (operandA > operandB);
                    case "lessthanequalto":
                        return (operandA <= operandB);
                    case "morethanequalto":
                        return (operandA >= operandB);
                    case "equal":
                        return (operandA == operandB);
                    case "notequal":
                        return (operandA != operandB);
                    default:
                        return false;
                }


I get compiler errors:

Operator '<' cannot be applied to operands of type 'T' and 'T'
.....
.....
AnswerRe: C# Generics - Using operators with generic objects Pin
Christian Graus4-Sep-07 4:43
protectorChristian Graus4-Sep-07 4:43 

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.