Click here to Skip to main content
15,909,445 members
Home / Discussions / C#
   

C#

 
Questionapp.config I can't add or remuve values. Pin
daavena21-Aug-08 1:55
daavena21-Aug-08 1:55 
AnswerRe: app.config I can't add or remuve values. Pin
leppie21-Aug-08 2:14
leppie21-Aug-08 2:14 
Questionhow get diffreent from one to another audio codecs using DirectxCapture Pin
anishkannan21-Aug-08 1:34
anishkannan21-Aug-08 1:34 
AnswerRe: how get diffreent from one to another audio codecs using DirectxCapture Pin
Christian Graus21-Aug-08 1:47
protectorChristian Graus21-Aug-08 1:47 
Questionconvert .wav to raw Pin
zumty21-Aug-08 1:18
zumty21-Aug-08 1:18 
AnswerRe: convert .wav to raw Pin
Christian Graus21-Aug-08 1:51
protectorChristian Graus21-Aug-08 1:51 
QuestionAdd two numbers in Generic Pin
.NET- India 21-Aug-08 0:05
.NET- India 21-Aug-08 0:05 
AnswerRe: Add two numbers in Generic Pin
Christian Graus21-Aug-08 0:17
protectorChristian Graus21-Aug-08 0:17 
T can be anything, including types which do not have operator + defined. Therefore, this doesn't work ( and is kind of dumb anyhow ). You can specify that T is a struct, or class, or impliments a certain interface, but I don't believe you can actually specify that it impliments +.

class Addition<T> where T : IDisposable

for example, will reject anything that does not impliment IDisposable, and so you can do

T.Dispose();

in your class, because you've defined it will be there. I am guessing you're looking for a simple example to play with generics, sorry the one you picked does not work. The only thing you know for sure about T is that it's an object, unless you add other constraints to your definition. You can try to cast T, but you can't assume anything else is there, unless you said it would be.

Christian Graus

No longer a Microsoft MVP, but still happy to answer your questions.

AnswerRe: Add two numbers in Generic Pin
Pete O'Hanlon21-Aug-08 1:48
mvePete O'Hanlon21-Aug-08 1:48 
AnswerRe: Add two numbers in Generic Pin
PIEBALDconsult21-Aug-08 3:20
mvePIEBALDconsult21-Aug-08 3:20 
QuestionException handling question Pin
Green Fuze20-Aug-08 22:51
Green Fuze20-Aug-08 22:51 
AnswerRe: Exception handling question Pin
Christian Graus20-Aug-08 23:18
protectorChristian Graus20-Aug-08 23:18 
QuestionMemory leaks tools Pin
tom groezer20-Aug-08 22:38
tom groezer20-Aug-08 22:38 
GeneralRe: Memory leaks tools Pin
selcuks20-Aug-08 22:50
selcuks20-Aug-08 22:50 
GeneralRe: Memory leaks tools Pin
tom groezer20-Aug-08 23:34
tom groezer20-Aug-08 23:34 
GeneralRe: Memory leaks tools Pin
leppie21-Aug-08 22:03
leppie21-Aug-08 22:03 
Questionstructure storage API Pin
Miss_hacker20-Aug-08 21:56
Miss_hacker20-Aug-08 21:56 
AnswerRe: structure storage API Pin
Christian Graus20-Aug-08 22:28
protectorChristian Graus20-Aug-08 22:28 
Questionstring comparasion Pin
AndieDu20-Aug-08 21:32
AndieDu20-Aug-08 21:32 
AnswerRe: string comparasion Pin
selcuks20-Aug-08 21:41
selcuks20-Aug-08 21:41 
GeneralRe: string comparasion Pin
AndieDu21-Aug-08 15:30
AndieDu21-Aug-08 15:30 
AnswerRe: string comparasion Pin
Christian Graus20-Aug-08 21:54
protectorChristian Graus20-Aug-08 21:54 
GeneralRe: string comparasion Pin
AndieDu21-Aug-08 15:31
AndieDu21-Aug-08 15:31 
QuestionA COM Interop Question Pin
Xiaoming Qian20-Aug-08 21:21
Xiaoming Qian20-Aug-08 21:21 
AnswerRe: A COM Interop Question Pin
AhsanS20-Aug-08 21:37
AhsanS20-Aug-08 21:37 

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.