Click here to Skip to main content
16,012,759 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

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

VB
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 code

C#
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--cannot implicitly convert string to int.

Can anyone help to avoid this error?

Thank you,
Posted
Comments
Manfred Rudolf Bihy 13-Jun-12 11:05am    
The answer was already given to you yesterday. Why this repost?

C#
if(i==Convert.ToInt32(e.Item.Value))
 
Share this answer
 
Comments
jaipal0908 13-Jun-12 10:56am    
Thank you
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900