In Main function another function is there and to that
function if we pass string as parameter ,then that string
value is passed by value or reference type?

Answer Posted / sultan

parameters are passed byvalue unless defined to be passed
as ref,

try this
inside MAIN
{
string a = "a";
console.writeline(a);
foo(a);
console.writeline(a);
foo1(ref a);
console.writeline(a);
console.readkey();
}

foo(string a)
{
a="b";
}
foo1(ref string a)
{

}
}

result:
a
a
b

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we need serialization?

442


How can I get around scope problems in a try/catch?

483


What are the fundamental differences between value types and reference types?

553


What is use of singleton class in c#?

497


Write a C# program to find the Factorial of n

558






What is the use of ienumerable?

459


Is nullable type c#?

496


What is public or shared assemblies ?

561


Is stringbuilder thread safe c#?

479


What are annotations in c#?

527


How do you define a predicate?

488


Can constructor be overloaded in c#?

481


How long has c# been around?

567


What are extensions in c#?

542


Is array thread safe c#?

482