• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

conversion from c# to java

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

Thanks for helping me out with answers here. I have one more question regarding conversion of c# into java.



Is this the right way to do this . I see there is something wrong.

Please let me know.

Thanks
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hardly a beginner's topic!

No, it is not the right way to do it. If you take the value of a char, you might get 'A' = 0x41 (65). You could try several things:

  • Integer.parseInt(myString.substring( . . .
  • Character#getNumericValue
  • charAt() - '0'
  • and there are bound to be others.
  • At least the parsing methods will throw a nice Exception if your char isn't a number!
     
    Avi Sridhar
    Ranch Hand
    Posts: 48
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Campbell Ritchie:
    Hardly a beginner's topic!

    No, it is not the right way to do it. If you take the value of a char, you might get 'A' = 0x41 (65). You could try several things:

  • Integer.parseInt(myString.substring( . . .
  • Character#getNumericValue
  • charAt() - '0'
  • and there are bound to be others.
  • At least the parsing methods will throw a nice Exception if your char isn't a number!


    Thanks for the reply.

    Reg. this : Integer.parseInt(myString.substring( . . .

    did you mean

     
    Campbell Ritchie
    Marshal
    Posts: 79180
    377
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Avi Sridhar:

    Thanks for the reply.

    Reg. this : Integer.parseInt(myString.substring( . . .

    did you mean

    Yes.
     
    Wait for it ... wait .... wait .... NOW! Pafiffle! A perfect tiny ad!
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic