----------------------------------------------------------- New Message on BDOTNET
----------------------------------------------------------- From: Mrinal Message 3 in Discussion Hi , First of all why do u really need to pass a reference type by value , it always saves memory to pass the reference instead of passing value , Passing by value is primarily done in System.ValueTypes , which are essentially primitive types supported by compiler , howveer they can be passed by refernce using ref or out keywords . You need to understand actually how does variable passing actually takes place : 1. Pass by Value -- For primitive types only and new memory is allocated every time . 2. Pass reference by value -- This is default for all refernce types i.e their reference / memory address is passed by value in default mode . 3. Pass refrence by reference - It is when you use keyword like ref , so , it will pass the reference to the actually existing reference . difference between 2 & 3 is in 2. even if one of the reference is nullified , then other one sustains same value and memory location , but in case 3. even original one is nullified , otehr one also nulls . refer to the link for more clear understanding of the same : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vclrfPassingMethodParameters.asp Now coming doen to your questions : 1. Object is the base type that essentially behaves like a reference type since memory is allocated on heap , so pass it by reference , no need to pass it by value . 2. String is immutable reference type , it is again reference type since memory gets allocated on heap but actually it behaves like a primitive type and when ever it's being passed in a function , then instead of creating a new reference to same memory location , a new memory is allocated on heap . 3.String even being a reference type is the only exception that is passed by value , You can always pass form objects reference in a method , but be sure that change that you do at one end will be reflected on the other as you are changing the same memory location in case of form object . 4. No " MarshalByRef " doesn't comes into picture out here , since it is meant for communication between two different processes , AppDomains where calls are being marshalled across the boundaries either by reference or by value , depending on various factors for e.g : In case of web services it is always marshalled by value , since it's a Remote communication , so by reference is not possible . hope it helps , regards , Mrinal ----------------------------------------------------------- To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings. http://groups.msn.com/bdotnet/_emailsettings.msnw Need help? If you've forgotten your password, please go to Passport Member Services. http://groups.msn.com/_passportredir.msnw?ppmprop=help For other questions or feedback, go to our Contact Us page. http://groups.msn.com/contact If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list. mailto:[EMAIL PROTECTED]
