Storing a reference to a string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt Burland

    Storing a reference to a string

    I was wondering what the correct way to do this is, in C++ I'd just use a
    string* :

    public class A
    {
    private string myString // I actually want to keep a reference, but
    I'm not sure of the syntax
    .....
    public A(ref string aString)
    {
    // This method has a reference to aString - Any changes to aString here will
    be passed back to the original string
    myString = aString // this will copy the string, but I want to be able
    to store the reference to the string instead
    }
    .....
    public void ChangeString()
    {
    myString = "Hello"; // I'd like this to change the original string that
    was passed to the constructor
    }

    cheers


Working...