Do not miss our Interview Question video series 30 Important C# Interview Questions : ruclips.net/video/BKynEBPqiIM/видео.html 25 Important ASP.NET Interview Questions : ruclips.net/video/pXmMdmJUC0g/видео.html 25 Angular Interview Questions : ruclips.net/video/-jeoyDJDsSM/видео.html 5 MSBI Interview Questions : ruclips.net/video/5E815aXAwYQ/видео.html
Covariance and Contravariance have been supported in prior versions in of .net. Actually .net 4.0 implements variance for generic interfaces and delegates using in and out key words. Note that for generic classes in .net 4.0, variance is NOT supported. ie List lstAnimal = new List(); will NOT compile.The video does not mention which feature is being introduced in .net 4.0 and which features it still has not implemented.
Covariance and Contra-variance have been a part of C# since 1.0 (.Net Framework 1.0) but earlier the parameters of methods used to be contra variant where as the return values used to be co-variant, with .Net 4.0 (with the introduction of 'in' and 'out' keywords it became possible to have both co-variant and contra-variant parameters for methods.
Moreover to add some more to it Covariance and Contravariance define where an implicit cast can happen automatically and where you need an explicit cast (when it come to precompile behaviour.)
Covariance and Contra-variance have been a part of C# since 1.0 (.Net Framework 1.0) but earlier the parameters of methods used to be contra variant where as the return values used to be co-variant, with .Net 4.0 (with the introduction of 'in' and 'out' keywords it became possible to have both co-variant and contra-variant parameters for methods. Arrays of reference types, for example have always been been co-variant right from C# 1.0 so it is perfectly valid to do this: Animal[] cats=new Cat[10]; but you would get a run-time exception if you try to do this: cats[0]=new Dog(); Even if try to do this in C# 4.5 because arrays in CLR are mutable and hence need to preserve assignment compatibility. And this is what Rajesh Kumar Yanuganti meant to say.
The video kind of implies that the covariance and contravariance are introduced for the first time in .Net 4.0, which is wrong. This is only consolidated in 4.0. Some form of it was working since .Net 1.0. So this video is not accurate.
but the array or list of these base clases is not compatible that is why Linq has Cast() extension method. but inl dot.net 4.0 that works. that's the point of the video.
This is very good, but you (uploader) cheated so bad on explaining contravariance. "Contravariance is the opposite of Covariance." 'Black is opposite of White' said the Master Painter. 'Now you know enough to paint.' Doesn't work with programming :D
Do not miss our Interview Question video series
30 Important C# Interview Questions : ruclips.net/video/BKynEBPqiIM/видео.html
25 Important ASP.NET Interview Questions : ruclips.net/video/pXmMdmJUC0g/видео.html
25 Angular Interview Questions : ruclips.net/video/-jeoyDJDsSM/видео.html
5 MSBI Interview Questions : ruclips.net/video/5E815aXAwYQ/видео.html
Covariance and Contravariance have been supported in prior versions in of .net. Actually .net 4.0 implements variance for generic interfaces and delegates using in and out key words. Note that for generic classes in .net 4.0, variance is NOT supported. ie List lstAnimal = new List(); will NOT compile.The video does not mention which feature is being introduced in .net 4.0 and which features it still has not implemented.
Can you provide a link to the contravarience video you mention in this video? I'm having trouble locating it. Thanks!
Covariance and Contra-variance have been a part of C# since 1.0 (.Net Framework 1.0) but earlier the parameters of methods used to be contra variant where as the return values used to be co-variant, with .Net 4.0 (with the introduction of 'in' and 'out' keywords it became possible to have both co-variant and contra-variant parameters for methods.
Moreover to add some more to it Covariance and Contravariance define where an implicit cast can happen automatically and where you need an explicit cast (when it come to precompile behaviour.)
@Rajesh kumar i have shown a actual demo that it is not working with previous version. Do you have any links or pointers to solidfy your statements.
Covariance and Contra-variance have been a part of C# since 1.0 (.Net Framework 1.0) but earlier the parameters of methods used to be contra variant where as the return values used to be co-variant, with .Net 4.0 (with the introduction of 'in' and 'out' keywords it became possible to have both co-variant and contra-variant parameters for methods.
Arrays of reference types, for example have always been been co-variant right from C# 1.0 so it is perfectly valid to do this:
Animal[] cats=new Cat[10];
but you would get a run-time exception if you try to do this:
cats[0]=new Dog();
Even if try to do this in C# 4.5 because arrays in CLR are mutable and hence need to preserve assignment compatibility.
And this is what Rajesh Kumar Yanuganti meant to say.
Where is next part which explains the contra variance? Thanks for the explanation of covariance.
Yeah, i'm liking these videos. Keep up the good work. Subscribed.
Very clear and concise - thank you!
can you tell me what is code variant related to algorithms
Please keep your word. In this video you told to cover contravariance in next video but there is no next video of yours which covers contravariance.
Thanks, excellent explanation.
Please provide a link to the contravarience video
contravariance video link?
great video. very clear
The video kind of implies that the covariance and contravariance are introduced for the first time in .Net 4.0, which is wrong. This is only consolidated in 4.0. Some form of it was working since .Net 1.0. So this video is not accurate.
but the array or list of these base clases is not compatible
that is why Linq has Cast() extension method. but inl dot.net 4.0 that works. that's the point of the video.
I get the idea, I just don't get when do you need this, can't you just use a new List of Animal-s?
This is very good, but you (uploader) cheated so bad on explaining contravariance. "Contravariance is the opposite of Covariance."
'Black is opposite of White' said the Master Painter. 'Now you know enough to paint.'
Doesn't work with programming :D
super.
The title of this video is misleading. At no point do you explain contravariance in detail.
Nice video, but you need to ber a pop filter, your plosives are rather distracting
Where is contravariance??
It's spelled 'kōˈve(ə)rēəns'.
Do you mean pronounced?
Please keep your word. In this video you told to cover contravariance in next video but there is no next video of yours which covers contravariance.