vb.net到c#.net的转换4.0 [英] vb.net to c#.net conversion 4.0

查看:98
本文介绍了vb.net到c#.net的转换4.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我将下面的VB.NET代码转换为C#.NET

Hi,

I am converting below VB.NET code to C#.NET

Protected Sub Menu1_MenuItemClick(ByVal sender As Object, ByVal e As MenuEventArgs) Handles Menu1.MenuItemClick
       MultiView1.ActiveViewIndex = Int32.Parse(e.Item.Value)
       Dim i As Integer
       For i = 0 To Menu1.Items.Count - 1
           If i = e.Item.Value Then
               Menu1.Items(i).ImageUrl = "selectedtab.gif"
           Else
               Menu1.Items(i).ImageUrl = "unselectedtab.gif"
           End If
       Next
   End Sub

   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       If Page.IsPostBack = False Then
           Menu1.Items(0).Selected = True
       End If
   End Sub



C#.NET代码



C#.NET code

protected void Page_Load(object sender, EventArgs e)
  {
      if (Page.IsPostBack == false)
      {
          Menu1.Items[0].Selected = true;
      }
  }

  protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
  {

      MultiView1.ActiveViewIndex = Int32.Parse(e.Item.Value);
      for (int i = 0; i < Menu1.Items.Count-1;i++)
      {
          if(i=e.Item.Value)
          {
              Menu1.Items[i].ImageUrl = "selectedtab.gif";
          }
          else
          {
              Menu1.Items[i].ImageUrl = "unselectedtab.gif";
          }
      }
  }




但是转换后,即时通讯在
出现错误




But after conversion Im getting an error at

if(i=e.Item.Value)



like-无法将字符串隐式转换为int.

任何人都可以帮助避免此错误吗?

谢谢您,



like--cannot implicitly convert string to int.

Can anyone help to avoid this error?

Thank you,

推荐答案

if(i==Convert.ToInt32(e.Item.Value))


要备份BRAHMA Brahman和Kumar Birajdar的答案-请访问以下站点:http://www.developerfusion.com/tools/convert/vb-to-csharp/ [
To back up the answer from BRAHMA Brahmanand Kumar Birajdar - have a look at this site: http://www.developerfusion.com/tools/convert/vb-to-csharp/[^]
It''s an online translator between VB and C#. Provided your VB compiles, it does a pretty good job of translating and can take a lot of the drudgery out of the process - I use it for QA answers.


这篇关于vb.net到c#.net的转换4.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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