Hi Ali,
Thank you for posting in the community!
Based on my understanding, you want to know if the string class is pass to
a method by value or by reference.
==============================
Just as the community stated, everything passed to a method is default by
value, unless it is marked by "ref" keyword, then it will by reference.
I want to point out that pass by value or by reference type has nothing to
do with the reference type or value type. That is, for reference type, it
also has 2 types: by value and by reference. Please see the 2 samples below:
1). Passing Reference Types by Value
using System;
class PassingRefByVal
{
static void Change(int[] arr)
{
arr[0]=888; // This change affects the original element.
arr = new int[5] {-3, -1, -2, -3, -4}; // This change is local.
Console.WriteLine("Inside the method, the first element is: {0}",
arr[0]);
}
public static void Main()
{
int[] myArray = {1,4,5};
Console.WriteLine("Inside Main, before calling the method, the first
element is: {0}", myArray [0]);
Change(myArray);
Console.WriteLine("Inside Main, after calling the method, the first
element is: {0}", myArray [0]);
}
}
Output
Inside Main, before calling the method, the first element is: 1
Inside the method, the first element is: -3
Inside Main, after calling the method, the first element is: 888
2). Passing Reference Types by Reference
using System;
class PassingRefByRef
{
static void Change(ref int[] arr)
{
// Both of the following changes will affect the original variables:
arr[0]=888;
arr = new int[5] {-3, -1, -2, -3, -4};
Console.WriteLine("Inside the method, the first element is: {0}",
arr[0]);
}
public static void Main()
{
int[] myArray = {1,4,5};
Console.WriteLine("Inside Main, before calling the method, the first
element is: {0}", myArray [0]);
Change(ref myArray);
Console.WriteLine("Inside Main, after calling the method, the first
element is: {0}", myArray [0]);
}
}
Output
Inside Main, before calling the method, the first element is: 1
Inside the method, the first element is: -3
Inside Main, after calling the method, the first element is: -3
~~~~~~~~~~~~
In the sample you will see that: for reference type by value, the
reference's content was not copied, but the reference variable self is
copied. So you can change the original reference variable's content, but
you can not change the reference variable itself.
So for string class without "ref" keyword, you "may" change the string
instance's content, but you can not change the string instance self.(That
is point to another string)
But, string class is a special class, whose content can not be modified. So
you can not do this:
string str="jeffrey";
f(str);
private void f(string str1)
{
str1[0]='a'; //this line will generate compile error
}
Hope I have clarified for you

For more information, please refer to:
"Passing Parameters"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/
vclrfPassingMethodParameters.asp
===================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.