Answer Posted / bharat
Hi All,By theoretical definition, it's true if we pass
parameter as value type we are passing a copy of value not
original copy.So changes are not reflect on original
value,now there is a catch what if i pass "Reef
type"(Classes,Delegates,Interface etc) as value type
e.g.
//------------------By Val
tryFunction TF1 = new tryFunction();
TF1.Age = 20;
TestFunction(TF1);
Response.Write(TF1.Age.ToString());
void TestFunction1(ref tryFunction tf)
{
tf.Age = 35;
}
public class tryFunction
{
private int age;
public int Age
{
set
{
age=value;
}
get{return age;}
}
-----------------------------------
Then what should be the return value.
According to concept it is 20,but on reality it is 35.So
where I am wrong?
| Is This Answer Correct ? | 0 Yes | 3 No |
Post New Answer View All Answers
What is using keyword?
What is the purpose of static?
Differentiate between copy and default constructor.
Give examples for value types?
Can we instantiate abstract class in c#?
Write a program to create a user control with name and surname as data members and login as method and also the code to call it. (Hint use event delegates) Practical Example of Passing an Events to delegates
What is type class in c#?
What are jump statements in c#?
Why extension method is static?
what happens if you inherit multiple interfaces and they have conflicting method names?
How are delegates chosen?
Int map to which .net types?
Is post back in c#?
How can you read 3rd line from a text file?
Does console.writeline() stop printing when it reaches a null character within a string?