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. Managed C++/CLI
  4. String pass by reference

String pass by reference

Scheduled Pinned Locked Moved Managed C++/CLI
c++
3 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.
  • C Offline
    C Offline
    carlo andreoli
    wrote on last edited by
    #1

    ok i'm anoob in cli and i'm sure this quesiton has a simple answer ...but i'm new to managed code so... what i wanna do is:

    void mod_str(String ^bb) {
    bb="bau";
    }
    void action() {
    String ^str="ciao";
    mod_str(str);
    this->button1->Text=str;
    }

    what i wanna is that this button1 text became "bau" but with this code it remains "ciao"... in c++ it wolud be something like...

    void mod_str(string &str) {
    str="bau";
    }

    void action() {
    string str="ciao";
    mod_str(str);
    ....
    }

    T 1 Reply Last reply
    0
    • C carlo andreoli

      ok i'm anoob in cli and i'm sure this quesiton has a simple answer ...but i'm new to managed code so... what i wanna do is:

      void mod_str(String ^bb) {
      bb="bau";
      }
      void action() {
      String ^str="ciao";
      mod_str(str);
      this->button1->Text=str;
      }

      what i wanna is that this button1 text became "bau" but with this code it remains "ciao"... in c++ it wolud be something like...

      void mod_str(string &str) {
      str="bau";
      }

      void action() {
      string str="ciao";
      mod_str(str);
      ....
      }

      T Offline
      T Offline
      teejayem
      wrote on last edited by
      #2

      instead of

      void mod_str(String ^bb) {
      bb="bau";
      }

      use

      void mod_str(String ^%bb) {
      bb="bau";
      }

      EDIT: This is a pretty good place to learn the keywords and operators specific to C++/CLI http://msdn.microsoft.com/en-us/library/xey702bw.aspx[^]

      Don't be overcome by evil, but overcome evil with good

      C 1 Reply Last reply
      0
      • T teejayem

        instead of

        void mod_str(String ^bb) {
        bb="bau";
        }

        use

        void mod_str(String ^%bb) {
        bb="bau";
        }

        EDIT: This is a pretty good place to learn the keywords and operators specific to C++/CLI http://msdn.microsoft.com/en-us/library/xey702bw.aspx[^]

        Don't be overcome by evil, but overcome evil with good

        C Offline
        C Offline
        carlo andreoli
        wrote on last edited by
        #3

        Thank you for this simple but important reply

        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