That’s silly. That’s not about a language feature. That’s about a compiler. The rest is about libs, framework.
More cherries.
![]()
Ok then.
Basically the pre Generics way when VB and C# used objects to ditch variants. Then non object types just got auto casted. So int got auto cast to Integer (which was object type carrying int, which made it work seamless when using it in dictionaries and in other places)
And yes it certainly was far better than “Variant” even if it had also issues, which of course the proper Generics in 2.0 took care of.
I think it also helped them with early Generics versions since I am pretty sure the early generics model they had did auto cast from int to Integer (object type) when hitting non objects.
It does not do it in today’s versions though, generics now carry basic types also there.
As I said, Generics access other kind of problem, they are not the “Variant” substitute. As even you say, the Variant option is an object of some kind cast to some value when needed.
Let’s try to explain, take for example:
Dim arrayOfAnything() As Variant
It does not exist in VB.Net and the equivalent is
Dim arrayOfAnything() As Object
Works flawlessly
What’s the “Generics” equivalent? No an “Array” but a List, of what? Objects. Same thing.
Dim listOfAnything As As New List(Of Object)
Again, the Variant equivalent is Object.
Generics is a powerful feature to set a specific type of something depending on what you need for your context, but that type, if it is an “Anything type” (like the old Variant), not a specific type (like Integer or String), will be an Object, the “container” of any type.
We are talking about today, not 2002, Object still is the tool, several other features came after (like the amazing Generics), but this exact one, is the one for this specific case since those days.