Results 1 to 5 of 5

Thread: Translating C++.Net code to C# - {RESOLVED}

  1. #1

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Translating C++.Net code to C# - {RESOLVED}

    I've seen the light, I've given up C++.net and as a result, I've got a large chunk of code to trawl through to move over to C#.

    One thing though, In C++ I used this to test whether a pointer had been initialised...

    Code:
    if(!pMyString)
    //it hasn't been initialised yet
    else
    //it has
    In C# I have changed the pointer into to a string variable.

    Now if I have:

    Code:
    string MyString;
    //...
    what is it's state now, it is null, nothing, empty, "" or what?

    And how do I test it.

    Thanks.

    PS, why didn't anyone tell me that Managed C++ was so arse?
    Last edited by wossname; Nov 27th, 2003 at 03:58 AM.
    I don't live here any more.

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Not one hundred percent:
    mystring != null

  3. #3
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    when initially creating the string, try this...
    VB Code:
    1. [Color=Blue]string[/color] MyString = [Color=Blue]string[/color].Empty;
    then you can check if the string is empty or not like this....
    VB Code:
    1. [Color=Blue]private[/color] [Color=Blue]void[/color] button1_Click([Color=Blue]object[/color] sender, System.EventArgs e)
    2.         {
    3.             [Color=Blue]string[/color] MyString = [Color=Blue]string[/color].Empty;
    4.             [Color=Blue]if[/color](MyString==[Color=Blue]string[/color].Empty)
    5.             {
    6.                  MessageBox.Show("it's empty");
    7.             }
    8.             [Color=Blue]else
    9. [/color]           {
    10.                  MessageBox.Show("it's NOT empty");
    11.             }
    12.         }
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  4. #4

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    That'll do it.

    Cheers.

  5. #5
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Originally posted by hellswraith
    Not one hundred percent:
    mystring != null
    i do believe it is null if you dont assign nothing to it, wouldnt it be if it was with any other object type?
    \m/\m/

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