Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 13th, 2007, 02:47 AM
Registered User
 
Join Date: Dec 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to viveksrivastava
Default Immutable objects in C#

What is meant by immutable objects in C#? Is it an instance of a class which has read only properties.

Vivek Srivastava
[email protected]
 
Old December 13th, 2007, 05:11 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Basically yes.

The String class is a good example of a immutable class. You cannot actually modify the string stored, only create new classes.

Hence the following does not 'modify' the string s, but creates a new variable with the new string containing the old value plus the new value:

s += "World";

For more details check out wikipedia: http://en.wikipedia.org/wiki/Immutable_object


/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Value objects rayback_2 BOOK: Beginning Cryptography with Java 1 May 13th, 2008 05:04 PM
asp objects and.ranieri Classic ASP Components 3 January 21st, 2005 05:40 AM
Returning Objects BSkelding Pro VB.NET 2002/2003 1 January 11th, 2005 10:22 AM
Com Objects henryh MySQL 0 July 2nd, 2003 03:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.