为何VB.Net检测为x86架构而C#检测为x64?(同配置同机器)
同一机器上VB与C#同逻辑代码输出不同问题
同一台计算机上,执行逻辑完全一致的VB和C#代码,却得到不同的输出结果。两个项目均采用AnyCPU运行配置,使用Visual Studio 2019开发。
VB代码
Private Shared Function getOSPlatForm() As String Dim OsPlatForm As String = Nothing If IntPtr.Size * 8 = 32 Then OsPlatForm = "X86" 'win 32bit Else OsPlatForm = "X64" 'win 64bit End If Return OsPlatForm End Function
输出结果:X86
C#代码
private static string getOSPlatForm() { string OsPlatForm = null; if (IntPtr.Size * 8 == 32) { OsPlatForm = "X86"; //win 32bit } else { OsPlatForm = "X64"; //win 64bit } return OsPlatForm; }
输出结果:X64
运行配置说明:两个项目的运行配置均设置为AnyCPU。
内容的提问来源于stack exchange,提问作者Edgar Lopez
相关产品推荐
相关产品推荐

