Closed Thread
Results 1 to 3 of 3

Thread: How references work?

  1. #1
    lumeneu is offline Newbie
    Join Date
    Jan 2010
    Posts
    9
    Rep Power
    0

    How references work?

    If the method parameter is a reference type I can modify it with a side effect without ref, right?

    And string is a reference type, right?

    So, why this: ideone.com/IEWpcEmr two calls do not behave in the same way? - Any help to explain this?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    QuackWare is offline Learning Programmer
    Join Date
    Jan 2010
    Posts
    95
    Rep Power
    8

    Re: How references work?

    Explanation taken from:

    Manipulating Strings in C# at C# Online.NET (CSharp-Online.NET)

    What makes string types really interesting is that in .NET strings are immutable—the contents of the buffer can't be changed. Languages like C# enable you to treat your string variable as a changeable type. For example, they let you append another string to the string in your variable. However, this is an illusion provided by the compiler. In reality, when you change the contents of your string, the compiler asks the .NET runtime to create a brand-new string object.

  4. #3
    lumeneu is offline Newbie
    Join Date
    Jan 2010
    Posts
    9
    Rep Power
    0

    Re: How references work?

    @QuackWare Thank you!

    so
    String s = "A";
    is equivalent to
    String s = new String("A");

    It seems to more understandable now, thanks!

    PS: also the csharp-online.net looks cool!

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Any good PHP example references?
    By NastyDevil in forum PHP Development
    Replies: 6
    Last Post: 06-25-2010, 05:46 AM
  2. references to a specific address
    By x42 in forum C and C++
    Replies: 13
    Last Post: 06-19-2010, 07:32 PM
  3. Objects and References
    By BlaineSch in forum General Programming
    Replies: 1
    Last Post: 09-16-2009, 09:03 AM
  4. Pointers/references
    By RobotGymnast in forum C and C++
    Replies: 31
    Last Post: 09-27-2008, 02:04 PM
  5. The Mug of Vi References
    By Jordan in forum Computer Software/OS
    Replies: 2
    Last Post: 03-03-2007, 12:37 PM

Tags for this Thread

Bookmarks

Posting Permissions

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