I’m working on an ASP.NET application and I’m trying to wrap my head around what it means when I see something like List<MyObject>. I actually have several other questions, but this is a good start. I’ve also tried finding some guides for migrating from ColdFusion to ASP MVC, but all I found was something from 2003. Thanks for any help 🙂
I’m working on an ASP.NET application and I’m trying to wrap my head around
Share
The angle brackets notation you’re referring to is called generics. They’re necessary (or at least very useful) in a statically typed language like C# or Java. What they’re saying is that this list is going to contain objects of type ‘MyObject’.
Once you’ve declared what kind of Object the List can hold, the IDE (and possibly the runtime) can check your code to make sure that you’re only putting objects of that type or subtype into the List.
Because ColdFusion is dynamically typed, the notion doesn’t make sense, which is why you don’t have the same notation in CFML/CFScript. The nearest equivalent to a List in Java/.Net is the Array in ColdFusion. That’ll let you put any kind of value into it. You could think of an Array in ColdFusion of being equivalent to List.