typeof() in c# != TypeOf in VB.NET

by robert 31. October 2009 20:54

  C#: typeof(someType) gibt den System.Type zurück VB.NET: TypeOf someType IS Integer gibt ein Boolean zurück Das Equivalent zu typeof() in VB.NET ist: GetType(Foo) Es hat ein wenig gedauert bis ich verstanden habe das die Beispiele auf der Autofac VB.NET Dokumentationsseite nicht korrekt sind… Dim builder As Autofac.ContainerBuilder = New Autofac.ContainerBuilder() builder.Register(TypeOf(Car)).As(TypeOf(IVehicle)) Dim container As Autofac.Container = builder.Build() … kann natürlich nicht funktieren! Es muß sein: Dim builder As Autofac.ContainerBuilder = New Autofac.ContainerBuilder() builder.Register(GetType(Car)).As(GetType(IVehicle)) Dim container As Autofac.Container = builder.Build()

enjoyed the post?

Tags:

VB.NET

About Oliver

shades-of-orange.com code blog logo I build web applications using ASP.NET and have a passion for javascript. Enjoy MVC 4 and Orchard CMS, and I do TDD whenever I can. I like clean code. Love to spend time with my wife and our children. My profile on Stack Exchange, a network of free, community-driven Q&A sites

About Anton

shades-of-orange.com code blog logo I'm a software developer at teamaton. I code in C# and work with MVC, Orchard, SpecFlow, Coypu and NHibernate. I enjoy beach volleyball, board games and Coke.