Search code examples
vb.netanonymous-typesoption-strict

VB.NET: Which As clause to use with anonymous type with Option Strict On?


Consider the requirement to always declare Option Strict On. We'll always need to declare variables with the As keyword. What would be the type of an anonymous type?

Example : Dim product As ... = New With { Key .Name = "paperclips", .Price = 1.29 }

What will follow the As?


Solution

  • try either setting Option Infer On at the top of the class or a project level