Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

help converting vb code to c#

  • 17-05-2010 09:23PM
    #1
    Registered Users, Registered Users 2 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