Today I will write about the way variance influences type checking in C#. Yes, the fact that one type can be passed to a generic method that requires another type, depends on these 2 small keywords we write before ‘T’ (or whatever 😉) in interface header.
Sztuka programowania 1454 dni, 20 godzin, 12 minut temu 96 źrodło rozwiń
Have you ever seen these mysterious ‘in’ and ‘out’ keywords in generic interfaces’ definitions? If so, you’ve probably already checked what it means, but if not… You better read this and the next post. So today we will talk about the basics of variance in our own generic interfaces.
Sztuka programowania 1460 dni, 20 godzin, 3 minuty temu 121 źrodło rozwiń
Sometimes it happens that we use mechanisms/features of specific language without beeing aware of it. That’s fine, but if you’ll want to discuss your code in a future to the audience or coworkers, soon or later you’ll be forced to learn it and understand (or at least name it using technical nomenclature). Therefore, today I’m going to discuss two related „mechanisms” of C# which are covariance and contravariance. Covariance Covariance is a type conversion from the specific type to the more general (ba...
Sztuka programowania 2355 dni, 8 godzin temu 187 źrodło rozwiń
Niedługo dostępny będzie C# 4.0. Z ciekawych rzeczy, które mają wprowadzić:dynamic - ciekawy, aczkolwiek niepokojący feature. W skrócie - dostaniemy typy nieokreślone z możliwością wywoływania na nich dowolnych metod, które będą bindowane dopiero w czasie wykonywania (w przypadku klas .NET-owych; dla obiektów COM i obiektów z interfejsem IDynamicObject magia jest jeszcze głębsza)...