CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > .NET Programming > C-Sharp Programming
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    C-Sharp Programming Post questions, answers, and comments about C#.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old November 7th, 2009, 08:42 AM
    tigershark tigershark is offline
    Junior Member
     
    Join Date: Nov 2009
    Posts: 3
    tigershark is an unknown quantity at this point (<10)
    Int.Parse vs. Convert.To

    Hey,

    Could someone please explain what is the differance between:

    int x = intParse(txtNum1.txt);
    int x = Convert.ToInt32(txtNum1.txt);


    Thanks,
    Dan.
    Reply With Quote
      #2    
    Old November 7th, 2009, 05:25 PM
    BigEd781 BigEd781 is offline
    Member +
     
    Join Date: Jun 2008
    Posts: 1,002
    BigEd781 is a glorious beacon of light (400+)BigEd781 is a glorious beacon of light (400+)BigEd781 is a glorious beacon of light (400+)BigEd781 is a glorious beacon of light (400+)BigEd781 is a glorious beacon of light (400+)BigEd781 is a glorious beacon of light (400+)
    Re: Int.Parse vs. Convert.To

    Int32.Parse - http://msdn.microsoft.com/en-us/libr...8VS.71%29.aspx
    Convert.ToInt32 - http://msdn.microsoft.com/en-us/libr...8VS.71%29.aspx

    The Convert class is capable of converting more types of data representations to an integer than Parse, which deals only with strings.
    Reply With Quote
      #3    
    Old November 9th, 2009, 04:03 AM
    boudino's Avatar
    boudino boudino is offline
    Senior Member
     
    Join Date: Mar 2004
    Location: Prague, Czech Republic, EU
    Posts: 1,342
    boudino is a splendid one to behold (750+)boudino is a splendid one to behold (750+)boudino is a splendid one to behold (750+)boudino is a splendid one to behold (750+)boudino is a splendid one to behold (750+)boudino is a splendid one to behold (750+)boudino is a splendid one to behold (750+)
    Re: Int.Parse vs. Convert.To

    There's no difference, Conver.ToInt32() internaly uses Int32.Parse(). Covert is just facade over various types. Int32(16,64) and so on provides, in addition to Convert's methods, TryParse family of safe method which not throw an exception.
    __________________
    • Make it run.
    • Make it right.
    • Make it fast.
    Don't hesitate to rate my post.
    Reply With Quote
      #4    
    Old November 9th, 2009, 04:29 AM
    TheSamuels TheSamuels is offline
    Junior Member
     
    Join Date: Oct 2009
    Posts: 8
    TheSamuels is an unknown quantity at this point (<10)
    Re: Int.Parse vs. Convert.To

    Yes, the difference is over what class is being called, the outcome offers no difference
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > .NET Programming > C-Sharp Programming


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 01:45 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009