vb.net – 我可以有条件地编译“Select Case”吗?
发布时间:2020-12-17 07:12:38 所属栏目:百科 来源:网络整理
导读:关于#If然后#Else( https://msdn.microsoft.com/en-us/library/tx6yas69.aspx)的MSDN文章为我提供了条件编译条件语句的基础知识. 我碰巧有更长的声明列表,必须根据多个平台进行不同的初始化.我是否需要在编译时使用#ElseIf,或者是否也有#Select Case选项?
关于#If然后#Else(
https://msdn.microsoft.com/en-us/library/tx6yas69.aspx)的MSDN文章为我提供了条件编译条件语句的基础知识.
我碰巧有更长的声明列表,必须根据多个平台进行不同的初始化.我是否需要在编译时使用#ElseIf,或者是否也有#Select Case选项? 解决方法
VB .Net中没有#Select Case指令(
as pointed out by Icepickle)
根据Conditional Compilation,您可以定义编译常量#Const并测试它们以包含或排除代码块. 如果您有许多不同的体系结构/平台,也许最好为每个平台编写不同的文件,并使用常量检查保护文件 首先,您声明一个接口,以便其余代码始终能够找到它所需的内容: Public Interface IPlatformDependant Property Test1 As Integer 'Define here all the parameters used by your application End Interface 文件platform1.vb: #If Platform = 1 'The code for the first platform Public Class PlatformDependant Implements IPlatformDependant Public Property Test1 As Integer Implements IPlatformDependant.Test1 End Class #End If 文件platform2.vb: #If Platform = 2 'The code for the second platform Public Class PlatformDependant Implements IPlatformDependant Public Property Test1 As Integer Implements IPlatformDependant.Test1 End Class #End If 在项目设计器中,您可以定义所需的平台,并且一次只能使用一个类PlatformDependant.这个名字甚至可以保持不变…… 这里的接口是可选的,但它确保您所有的类都实现了所需的方法. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- c – Boost :: Geometry:如何在multi_polygon中加入相交的
- [转]Flash Builder 4 官网下载、安装与注册
- Ajax,python数据库,cgi,
- 在PHP中编码JSON以在iPhone应用程序中使用
- 详解Vue中localstorage和sessionstorage的使用
- 从PRISM开始学WPF(七)MVVM(三)事件聚合器EventAggregat
- Flex中相机不能正确显示视频可能由于系统配置问题
- Swift 开发:UINavigationController和UITabBarController用
- ruby-on-rails – 多线程并发Capybara请求?
- ActionScript 3.0 Step By Step系列文章索引