【问题标题】:How to convert code in Visual Basic to C#如何将 Visual Basic 中的代码转换为 C#
【发布时间】:2011-03-03 09:14:01
【问题描述】:

这是VB.NET中的代码:

Protected Overrides ReadOnly Property CreateParams() As CreateParams
    Get
        Dim CP As CreateParams = MyBase.CreateParams
        CP.Style = &HA0000
        Return CP
    End Get

我想把它转换成 C#。根据我的假设,下面是 C# 中的代码的样子。对于上面CP.Style = &HA000的代码,我应该输入什么 C# 代码。我把它留空了。

protected override CreateParams CreateParams
{
    get
    {
        CreateParams cp = base.CreateParams;
        cp.Style = 
        return cp;
    }
}

【问题讨论】:

  • 一种通用的方法是编译代码,然后在reflector 中反汇编它。请注意,reflector 很快就会真的停止免费使用。

标签: c# .net vb.net vb.net-to-c#


【解决方案1】:

你需要:

CreateParams cp = base.CreateParams;
cp.Style = 0xA000;
return cp;

0x 是 C# 中十六进制整数文字的前缀,而不是 VB 中的 &H

【讨论】:

    【解决方案2】:

    缺少一行:

    cp.Style = 0xA0000;
    

    【讨论】:

      【解决方案3】:
      protected override CreateParams CreateParams {
          get {
              CreateParams CP = base.CreateParams;
              CP.Style = 0xa0000;
              return CP;
          }
      }
      

      Try this convertor

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-06-09
        • 2022-01-22
        • 1970-01-01
        • 2011-04-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多