Click here to Skip to main content
15,889,704 members
Home / Discussions / C#
   

C#

 
GeneralRe: generics question Pin
George_George11-May-08 15:18
George_George11-May-08 15:18 
GeneralRe: generics question Pin
S. Senthil Kumar11-May-08 19:31
S. Senthil Kumar11-May-08 19:31 
GeneralRe: generics question Pin
George_George11-May-08 21:45
George_George11-May-08 21:45 
GeneralRe: generics question Pin
S. Senthil Kumar11-May-08 22:45
S. Senthil Kumar11-May-08 22:45 
GeneralRe: generics question Pin
George_George11-May-08 23:06
George_George11-May-08 23:06 
GeneralRe: generics question Pin
S. Senthil Kumar11-May-08 23:59
S. Senthil Kumar11-May-08 23:59 
GeneralRe: generics question Pin
George_George12-May-08 1:28
George_George12-May-08 1:28 
GeneralRe: generics question Pin
S. Senthil Kumar12-May-08 2:17
S. Senthil Kumar12-May-08 2:17 
George_George wrote:
1.

I want to confirm that the answer to my question #3 is, C# is using constraints to check whether a type is supported or not, but C++ will generate the specific type to check whether the operation is supported or not, right?


Yes, the C++ compiler compiles the expanded template as part of the normal compilation mechanism.


George_George wrote:
But from your sample below, I learned more. It seems C# compiler will check more than just the constraints, in your sample, without constraints, it will parse the invoked method to see whether it is supported, right?


Well, as part of compilation, it'll know that you called SayHello on the generic member, but it has no way of knowing whether the generic member has a SayHello. That's why it needs you to constrain the list of types that can be "substituted" for the generic member.

Regards
Senthil [MVP - Visual C#]
_____________________________
My Blog | My Articles | My Flickr | WinMacro

GeneralRe: generics question Pin
George_George12-May-08 2:32
George_George12-May-08 2:32 
QuestionFile header processing... [modified] Pin
natsuyaki10-May-08 22:00
natsuyaki10-May-08 22:00 
AnswerRe: File header processing... Pin
DanB198310-May-08 23:14
DanB198310-May-08 23:14 
GeneralRe: File header processing... Pin
natsuyaki10-May-08 23:34
natsuyaki10-May-08 23:34 
GeneralRe: File header processing... Pin
DanB198310-May-08 23:52
DanB198310-May-08 23:52 
GeneralRe: File header processing... Pin
natsuyaki10-May-08 23:59
natsuyaki10-May-08 23:59 
AnswerRe: File header processing... Pin
boblaw9911-May-08 4:13
boblaw9911-May-08 4:13 
GeneralRe: File header processing... Pin
natsuyaki11-May-08 4:24
natsuyaki11-May-08 4:24 
AnswerRe: File header processing... Pin
boblaw9911-May-08 5:03
boblaw9911-May-08 5:03 
GeneralRe: File header processing... Pin
natsuyaki11-May-08 5:16
natsuyaki11-May-08 5:16 
AnswerRe: File header processing... Pin
boblaw9911-May-08 5:22
boblaw9911-May-08 5:22 
GeneralRe: File header processing... Pin
natsuyaki11-May-08 5:34
natsuyaki11-May-08 5:34 
Questionmeta data and attribute Pin
George_George10-May-08 21:43
George_George10-May-08 21:43 
AnswerRe: meta data and attribute Pin
natsuyaki10-May-08 22:05
natsuyaki10-May-08 22:05 
GeneralRe: meta data and attribute Pin
George_George10-May-08 22:21
George_George10-May-08 22:21 
GeneralRe: meta data and attribute Pin
natsuyaki10-May-08 22:36
natsuyaki10-May-08 22:36 
GeneralRe: meta data and attribute Pin
George_George10-May-08 22:41
George_George10-May-08 22:41 

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.