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

What is use of singleton class in c#?

677


In which situation(s), the use of "Delegate" is a good idea?

742


What is datarelation c#?

648


Can delegates be used as callbacks?

662


Why we use get set property in c#?

682


What are object pooling and connection pooling and difference between them?

703


What are the types of serialization?

716


What does static mean in c sharp?

788


What type of data type conversion happens when the compiler encounters the following code?

715


What is default constructor in c#?

665


Name which controls do not have events?

774


What do you mean by expression tree?

611


What are the concepts of dispose method?

678


What is the purpose of abstract class in c#?

659


What is sorting in c#?

677