Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

help converting vb code to c#

Options
  • 17-05-2010 9:23pm
    #1
    Registered Users Posts: 872 ✭✭✭


    Hi,

    I am using web services with a CRM system and found a VB.net sample which works great. I need to convert it into C# so it works with my project. I am using an online vb to c# translator but it's not converting 100%

    VB CODE
    Dim l_ref As Lead.Lead
    
            l_ref = New Lead.Lead()
    
            l_ref.Url = Session("baseURL") + "/Lead"
    
            l_ref.CookieContainer = New System.Net.CookieContainer
    
            l_ref.CookieContainer.SetCookies(New Uri(Session("baseURL")), Session("Sessionid"))
    
            Dim l_input As Lead.LeadWS_LeadInsert_Input
    
            Dim l_output As Lead.LeadWS_LeadInsert_Output
    
            l_input = New Lead.LeadWS_LeadInsert_Input
    
            Dim l As Lead.Lead1
    
            l = New Lead.Lead1
    
            l.LeadFirstName = "Huckleberry"
            l.LeadLastName = "Finn"
            l.Company = "Pirate inc"
            'l.LeadOwner = "test"
    
            'l.Source = "web"
    
            Dim Lofl(1) As Lead.Lead1
    
            Lofl(0) = l
    
            l_input.ListOfLead = Lofl
    
            l_output = l_ref.LeadInsert(l_input)
    
            Server.Transfer("done.aspx", True)
    

    THE C# TRANSLATION (the *'s are appearing when i save this post)
    
    {
    * * Lead.Lead l_ref = default(Lead.Lead);
    * * 
    * * l_ref = new Lead.Lead();
    * * 
    * * l_ref.Url = Session("baseURL") + "/Lead";
    * * 
    * * l_ref.CookieContainer = new System.Net.CookieContainer();
    * * 
    * * l_ref.CookieContainer.SetCookies(new Uri(Session("baseURL")), Session("Sessionid"));
    * * 
    * * Lead.LeadWS_LeadInsert_Input l_input = default(Lead.LeadWS_LeadInsert_Input);
    * * 
    * * Lead.LeadWS_LeadInsert_Output l_output = default(Lead.LeadWS_LeadInsert_Output);
    * * 
    * * l_input = new Lead.LeadWS_LeadInsert_Input();
    * * 
    * * Lead.Lead1 l = default(Lead.Lead1);
    * * 
    * * l = new Lead.Lead1();
    * * 
    * * l.LeadFirstName = "Huckleberry";
    * * l.LeadLastName = "Finn";
    * * l.Company = "Pirate inc";
    * * //l.LeadOwner = "test"
    * * 
    * * //l.Source = "web"
    * * 
    * * Lead.Lead1[] Lofl = new Lead.Lead1[2];
    * * 
    * * Lofl(0) = l;
    * * 
    * * l_input.ListOfLead = Lofl;
    * * 
    * * l_output = l_ref.LeadInsert(l_input);
    * * 
    * * Server.Transfer("done.aspx", true);
    }
    
    

    It seems to be going wrong where it says
    Lead.Lead1[] Lofl = new Lead.Lead1[2];
    

    Does anyone have any idea how to properly convert this line ? I'm not really familar with VB !!

    Thanks in advance


Comments

Advertisement