Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Coverting string to int32

Coverting string to int32

Scheduled Pinned Locked Moved C#
csharpvisual-studiohelplearning
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    datainjector
    wrote on last edited by
    #1

    Just started C# and the compiler i am using is VS 7.0.When i try to convert a string literal to a integer my compiler is giving me problems.I have three books and i have tried all the examples on the book but they dont work. using System; class Hello { public static void Main(string[] args) { string s1 = "123"; int num = s1.ToInt32; } } Error:C:\Documents and Settings\KARANSANDHU\My Documents\Visual Studio Projects\ConsoleApplication1\Class1.cs(8): 'string' does not contain a definition for 'ToInt32'

    T 1 Reply Last reply
    0
    • D datainjector

      Just started C# and the compiler i am using is VS 7.0.When i try to convert a string literal to a integer my compiler is giving me problems.I have three books and i have tried all the examples on the book but they dont work. using System; class Hello { public static void Main(string[] args) { string s1 = "123"; int num = s1.ToInt32; } } Error:C:\Documents and Settings\KARANSANDHU\My Documents\Visual Studio Projects\ConsoleApplication1\Class1.cs(8): 'string' does not contain a definition for 'ToInt32'

      T Offline
      T Offline
      Tomas Petricek
      wrote on last edited by
      #2

      You can try one of following:

      int num = Int32.Parse(s1);
      int num = Convert.ToInt32(s1);

      i'm only pointer to myself

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups