Click here to Skip to main content
15,886,199 members
Home / Discussions / C#
   

C#

 
GeneralRe: treeView Pin
mihksoft18-Apr-07 7:09
mihksoft18-Apr-07 7:09 
QuestionCan I create a class from a string name?? Pin
Saeed.39418-Apr-07 6:15
Saeed.39418-Apr-07 6:15 
AnswerRe: Can I create a class from a string name?? Pin
Ravi Bhavnani18-Apr-07 6:57
professionalRavi Bhavnani18-Apr-07 6:57 
GeneralRe: Can I create a class from a string name?? Pin
sarvesh.upadhyay18-Apr-07 18:33
professionalsarvesh.upadhyay18-Apr-07 18:33 
AnswerRe: Can I create a class from a string name?? Pin
Saeed.39418-Apr-07 18:40
Saeed.39418-Apr-07 18:40 
Questionworking with mouse Pin
duta18-Apr-07 6:03
duta18-Apr-07 6:03 
AnswerRe: working with mouse Pin
Ed.Poore18-Apr-07 7:20
Ed.Poore18-Apr-07 7:20 
QuestionHandling the Generic Variable in a Generic Method Pin
BradleyC18-Apr-07 5:23
BradleyC18-Apr-07 5:23 
I am trying to write some some methods which will apply the System.Math methods to arrays instead of individual variables. I thought I might try a generic method (my attempt is below).

public static T[] Abs<T>(T[] array)
{
T[] absArray = array;
for (int i = 0; i < array.GetLength(0); i++)
{
absArray[i] = Math.Abs(absArray[i]);
}
return absArray;
}

The problem comes with the actual call the Math.Abs. The compiler complains:
Error 56 The best overloaded method match for 'System.Math.Abs(sbyte)' has some invalid arguments
Error 57 Argument '1': cannot convert from 'T' to 'sbyte'

Since the compiler doesn't know what type T is, I understand what is happening, but is there a way to make this work (or a better way to do this)?

I was just trying to keep from having to write several identical overloaded methods with differing types (and learn something in the process).


___________________
Brad
AnswerRe: Handling the Generic Variable in a Generic Method Pin
Tarakeshwar Reddy18-Apr-07 5:52
professionalTarakeshwar Reddy18-Apr-07 5:52 
GeneralRe: Handling the Generic Variable in a Generic Method Pin
BradleyC18-Apr-07 10:13
BradleyC18-Apr-07 10:13 
QuestionRegistration of a file type in C# Pin
manustone18-Apr-07 5:00
manustone18-Apr-07 5:00 
AnswerRe: Registration of a file type in C# Pin
Ravi Bhavnani18-Apr-07 7:00
professionalRavi Bhavnani18-Apr-07 7:00 
QuestionHow to fill Datagridview faster Pin
Kshitij Patel18-Apr-07 4:37
Kshitij Patel18-Apr-07 4:37 
AnswerRe: How to fill Datagridview faster Pin
MoustafaS18-Apr-07 4:48
MoustafaS18-Apr-07 4:48 
QuestionC# GUI display option Pin
atramard18-Apr-07 4:28
atramard18-Apr-07 4:28 
AnswerRe: C# GUI display option Pin
Pualee18-Apr-07 4:44
Pualee18-Apr-07 4:44 
GeneralRe: C# GUI display option Pin
atramard18-Apr-07 5:07
atramard18-Apr-07 5:07 
GeneralRe: C# GUI display option Pin
Dave Kreskowiak18-Apr-07 7:02
mveDave Kreskowiak18-Apr-07 7:02 
AnswerRe: C# GUI display option Pin
atramard18-Apr-07 20:09
atramard18-Apr-07 20:09 
QuestionDataSet.WriteXML Issue Pin
Pualee18-Apr-07 4:01
Pualee18-Apr-07 4:01 
QuestionC# code highlight as in Visual Studio Pin
Patrick Klug18-Apr-07 2:31
Patrick Klug18-Apr-07 2:31 
AnswerRe: C# code highlight as in Visual Studio Pin
Ed.Poore18-Apr-07 7:22
Ed.Poore18-Apr-07 7:22 
Questiondisplaying data in more than one textbox C# Pin
Deques18-Apr-07 1:56
Deques18-Apr-07 1:56 
AnswerRe: displaying data in more than one textbox C# Pin
sujithkumarsl18-Apr-07 2:05
sujithkumarsl18-Apr-07 2:05 
AnswerRe: displaying data in more than one textbox C# Pin
J4amieC18-Apr-07 2:09
J4amieC18-Apr-07 2:09 

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.