Results 1 to 9 of 9

Thread: [1.0/1.1] Converting Integer to String in C#

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2006
    Posts
    73

    [1.0/1.1] Converting Integer to String in C#

    hi all,
    i know this is really simple. but i still get it wrong. i try to do this:

    int intLen = 100;
    string StrLen;

    StrLen = intLen;
    MessageBox StrLen;

    i got error. Y?

    longwar

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [1.0/1.1] Converting Integer to String in C#

    Every object has a ToString method:
    Code:
    myString = anyObject.ToString();
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2006
    Posts
    73

    Re: [1.0/1.1] Converting Integer to String in C#

    ic ... i got it. tot it is the same as in VB

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [1.0/1.1] Converting Integer to String in C#

    It's exactly the same as VB. Same framework. Just different syntax.

    If your problem is fixed please go to Thread Tools (above the first post) and click Mark Thread Resolved. Thanks

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [1.0/1.1] Converting Integer to String in C#

    When you're dealing with types from the .NET Framework it's always going to be essentially the same regardless of language. The only difference is the syntax of the langauge, like in C# you need the semicolon obviously, and in C# if you're indexing a property you use square brackets instead of parentheses. Just little stuff like that. all the types and members are exactly the same though.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6
    Fanatic Member x-ice's Avatar
    Join Date
    Mar 2004
    Location
    UK
    Posts
    671

    Re: [1.0/1.1] Converting Integer to String in C#

    Won't using ToString on an Integer just return its memory address?

  7. #7
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [1.0/1.1] Converting Integer to String in C#

    Why don't you try it and see.

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [1.0/1.1] Converting Integer to String in C#

    Why would converting anything to a string return a memory address? C# doesn't expose memory addresses at all except through unsafe code, and then it is with pointers. The whole point of reference types is to hide memory addresses and pointers from the developer.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9
    Fanatic Member x-ice's Avatar
    Join Date
    Mar 2004
    Location
    UK
    Posts
    671

    Re: [1.0/1.1] Converting Integer to String in C#

    Quote Originally Posted by jmcilhinney
    Why would converting anything to a string return a memory address? C# doesn't expose memory addresses at all except through unsafe code, and then it is with pointers. The whole point of reference types is to hide memory addresses and pointers from the developer.
    Ah, thanks for the info

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width