混合VB.NET的Option Strict和新的Option Infer指令的最佳方法是什么? [英] What is the best way to mix VB.NET's Option Strict and the new Option Infer directives?

查看:111
本文介绍了混合VB.NET的Option Strict和新的Option Infer指令的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在与相关的问题中,我的团队即将(希望)开始使用LINQ,并且我想利用匿名类型.混合使用VB.NET的Option Strict(在项目的整个生命周期中一直在使用)和新的Option Infer指令的最佳方法是什么?

In a related question, my team is about to (hopefully) start using LINQ, and I'd like to take advantage of anonymous types. What is the best way to mix VB.NET's Option Strict (which we've been using through the life of the project) and the new Option Infer directives?

推荐答案

Option Strict和 Option Infer 不会发生冲突,因此将两者同时启用没有什么害处.

Option Strict and Option Infer do not conflict, so I see no harm in having both on.

作为样式指南,我更喜欢将Option Strict,Explicit和Infer放在每个类文件的顶部-这样可以防止项目或IDE设置中的差异引起问题,并清楚使用了哪些设置.

As a style guide, I prefer to put Option Strict, Explicit, and Infer at the top of each class file - this prevents differences in project or IDE settings from causing issues, and makes it clear what settings are used.

这篇关于混合VB.NET的Option Strict和新的Option Infer指令的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆