Please see my other C# articles.
Writing flexible, elegant code for data storage.
When writing business logic, it’s often difficult to determine at design-time what type an object will need to be or what type of data it will store.
Thankfully, Microsoft has provided an elegant solution by allowing developers to write code that will store any type of data without declaring its type.
To illustrate this feature, I’ll begin with a simple array of string objects, but notice that aside from that type of data used, no where do I explicitly state that the “localVar” variable is of a String type.
Upon executing my controller which calls the default Index() view, you will see the compiler correctly deduced the variable’s data type as String and displayed the results.