You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 08:20:31