Click here to Skip to main content
15,897,226 members
Home / Discussions / C#
   

C#

 
GeneralRe: problem in Datagrid Pin
Drew McGhie19-Jan-07 4:55
Drew McGhie19-Jan-07 4:55 
QuestionSSIS Component Pin
NK718-Jan-07 23:12
NK718-Jan-07 23:12 
AnswerRe: SSIS Component Pin
Mircea Puiu19-Jan-07 1:24
Mircea Puiu19-Jan-07 1:24 
QuestionSSIS Package Creation Pin
NK718-Jan-07 23:09
NK718-Jan-07 23:09 
Questionchanging color of the pointed treeView node Pin
samtam18-Jan-07 22:15
samtam18-Jan-07 22:15 
AnswerRe: changing color of the pointed treeView node Pin
Christian Graus18-Jan-07 22:57
protectorChristian Graus18-Jan-07 22:57 
AnswerRe: changing color of the pointed treeView node Pin
Mircea Puiu19-Jan-07 1:03
Mircea Puiu19-Jan-07 1:03 
QuestionGeneric sum Pin
V. Thieme18-Jan-07 22:15
V. Thieme18-Jan-07 22:15 
Hello all!

I would like to write a method like this:

public static T Sum<T>(T[] data)
{
     T s = default(T);
     if(data.Length == 0)
        throw new ArgumentException("No data!");
     for(int i = 0; 0 < data.Length; i++)
     {
          s = s + data[i];
     }
     return s;
}


Unfortunately this code doesn't work.
Compiler Error: The operator "+" can not be applied to operands of type "T" and "T".
What's wrong? Are there any constraints to apply?

Thank's in advance!



*************************
Do, ut des.

AnswerRe: Generic sum Pin
Russell Jones18-Jan-07 22:38
Russell Jones18-Jan-07 22:38 
GeneralRe: Generic sum Pin
V. Thieme18-Jan-07 23:37
V. Thieme18-Jan-07 23:37 
AnswerRe: Generic sum Pin
Christian Graus18-Jan-07 22:57
protectorChristian Graus18-Jan-07 22:57 
GeneralRe: Generic sum Pin
V. Thieme18-Jan-07 23:36
V. Thieme18-Jan-07 23:36 
QuestionLoading an image as a byte array Pin
Russell Jones18-Jan-07 22:11
Russell Jones18-Jan-07 22:11 
AnswerRe: Loading an image as a byte array Pin
Christian Graus18-Jan-07 22:56
protectorChristian Graus18-Jan-07 22:56 
GeneralRe: Loading an image as a byte array Pin
Russell Jones18-Jan-07 23:01
Russell Jones18-Jan-07 23:01 
AnswerRe: Loading an image as a byte array Pin
Guffa18-Jan-07 22:56
Guffa18-Jan-07 22:56 
AnswerRe: Loading an image as a byte array Pin
Luc Pattyn18-Jan-07 23:03
sitebuilderLuc Pattyn18-Jan-07 23:03 
GeneralRe: Loading an image as a byte array Pin
Russell Jones18-Jan-07 23:02
Russell Jones18-Jan-07 23:02 
GeneralRe: Loading an image as a byte array Pin
Luc Pattyn18-Jan-07 23:10
sitebuilderLuc Pattyn18-Jan-07 23:10 
GeneralRe: Loading an image as a byte array Pin
Russell Jones18-Jan-07 23:39
Russell Jones18-Jan-07 23:39 
GeneralRe: Loading an image as a byte array Pin
Luc Pattyn18-Jan-07 23:46
sitebuilderLuc Pattyn18-Jan-07 23:46 
Generalbug in doc Pin
Luc Pattyn18-Jan-07 23:58
sitebuilderLuc Pattyn18-Jan-07 23:58 
GeneralRe: bug in doc Pin
Russell Jones19-Jan-07 0:32
Russell Jones19-Jan-07 0:32 
QuestionData Transfer to new table Pin
Bulky Fellow18-Jan-07 22:06
Bulky Fellow18-Jan-07 22:06 
AnswerRe: Data Transfer to new table Pin
mihksoft18-Jan-07 22:49
mihksoft18-Jan-07 22:49 

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.