Click here to Skip to main content
15,917,610 members
Home / Discussions / C#
   

C#

 
GeneralRe: Downloading file from remote location Pin
kaliem2-Jul-07 10:07
kaliem2-Jul-07 10:07 
GeneralRe: Downloading file from remote location Pin
Scott Dorman2-Jul-07 10:43
professionalScott Dorman2-Jul-07 10:43 
GeneralRe: Downloading file from remote location Pin
Not Active2-Jul-07 10:59
mentorNot Active2-Jul-07 10:59 
QuestionC# Generic: Is this a bug or by design Pin
mschuckmann2-Jul-07 7:37
mschuckmann2-Jul-07 7:37 
AnswerRe: C# Generic: Is this a bug or by design Pin
Luc Pattyn2-Jul-07 8:03
sitebuilderLuc Pattyn2-Jul-07 8:03 
GeneralRe: C# Generic: Is this a bug or by design Pin
mschuckmann2-Jul-07 8:26
mschuckmann2-Jul-07 8:26 
GeneralRe: C# Generic: Is this a bug or by design Pin
Luc Pattyn2-Jul-07 9:08
sitebuilderLuc Pattyn2-Jul-07 9:08 
GeneralRe: C# Generic: Is this a bug or by design Pin
mschuckmann2-Jul-07 11:28
mschuckmann2-Jul-07 11:28 
Luc Pattyn wrote:
That is not correct: you dont loose all information, both the Generic method and the
SomeMethod method accept Base objects or Base derivatives, and these objects keep their characteristics.


The objects themselves may keep their characteristics, because after all they are objects, but they no longer behave like themselves the with respect to non-virtual methods and this is counter intuitive to anyone who has done extensive template programing.


Luc Pattyn wrote:
It is only the way you define your classes (thru the virtual/override/new keywords)
that decides whether you get the functionality of the base method or the more specialized
method. That has nothing to do with generics.


But the symantics of how they've implimented the generic feature makes the object behave differently with in the code of the generic (effectively making it lose it's type within the Generic), what is the point of providing the generic with specific type information (i.e. printName<child>(c) ) on the type I'm passing it if it's just going to ignore it and staticely the object to the lowest common denominator implimentation for non-virtual methods. In my opinion this hugely limits the functionality of generics when compared to templates and I find it hard to believe that anyone actually thinks this is good behavior.

Luc Pattyn wrote:
That is correct if you use where T : type.
But generics can be used without type constraint (acting somewhat like C++ templates).
And they can be used with more complex constraints; read up on "where" in MSDN for that.


If you leave out the where constraint you've essentially specified a generic with a constraint of object and you can't call any methods except those declared by object. Therefore my example code will not compile without the where constraint. So sure you can impliment generics without type constraints but don't expect to do anything interesting in your generic code.

C++ templates effectively impliment constraints but much more flexibly and without any new confusing and limiting syntax. They do this by verifying any type they are instantiated with impliment (or claim to impliment) any methods that are is used by the template at compile time.



Thanks again
Matt S.
GeneralRe: C# Generic: Is this a bug or by design Pin
Tim Paaschen2-Jul-07 20:36
Tim Paaschen2-Jul-07 20:36 
QuestionMultiview Databinding Pin
stormcandi2-Jul-07 6:19
stormcandi2-Jul-07 6:19 
AnswerRe: Multiview Databinding Pin
Sathesh Sakthivel2-Jul-07 16:22
Sathesh Sakthivel2-Jul-07 16:22 
QuestionInsert from DataTable into an SQL Table Pin
kissa492-Jul-07 5:52
kissa492-Jul-07 5:52 
JokeRe: Insert from DataTable into an SQL Table Pin
Ed.Poore2-Jul-07 6:13
Ed.Poore2-Jul-07 6:13 
GeneralRe: Insert from DataTable into an SQL Table Pin
kissa492-Jul-07 6:36
kissa492-Jul-07 6:36 
GeneralRe: Insert from DataTable into an SQL Table Pin
Ed.Poore2-Jul-07 6:54
Ed.Poore2-Jul-07 6:54 
GeneralRe: Insert from DataTable into an SQL Table Pin
leppie2-Jul-07 7:21
leppie2-Jul-07 7:21 
QuestionRe: Insert from DataTable into an SQL Table Pin
kissa492-Jul-07 8:34
kissa492-Jul-07 8:34 
AnswerRe: Insert from DataTable into an SQL Table Pin
PIEBALDconsult2-Jul-07 11:05
mvePIEBALDconsult2-Jul-07 11:05 
GeneralRe: Insert from DataTable into an SQL Table Pin
kissa492-Jul-07 11:06
kissa492-Jul-07 11:06 
GeneralRe: Insert from DataTable into an SQL Table Pin
PIEBALDconsult3-Jul-07 7:07
mvePIEBALDconsult3-Jul-07 7:07 
GeneralRe: Insert from DataTable into an SQL Table Pin
kissa493-Jul-07 8:18
kissa493-Jul-07 8:18 
GeneralRe: Insert from DataTable into an SQL Table [modified] Pin
PIEBALDconsult3-Jul-07 11:56
mvePIEBALDconsult3-Jul-07 11:56 
GeneralRe: Insert from DataTable into an SQL Table Pin
kissa494-Jul-07 8:32
kissa494-Jul-07 8:32 
QuestionReading a block of data from a file Pin
I.explore.code2-Jul-07 5:50
I.explore.code2-Jul-07 5:50 
AnswerRe: Reading a block of data from a file Pin
Luc Pattyn2-Jul-07 6:11
sitebuilderLuc Pattyn2-Jul-07 6:11 

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.