T
Tal
Is there a way to pass class object to a method in CSharp and be sure that
nothing will change (like writing const in C++).
For example if I have
class testClass
{
int t;
}
testClass tc = new testClass();
tc.t = 99;
And then I'm using it like:
aObj.DoSomething (tc);
I cannot be sure that the t value will not change, although I didn't use ref
or out keywords.
Of course I can copy the tc to another local variable and then sending the
copied object, but if testClass is a huge class, I will pay for it on run
time.
nothing will change (like writing const in C++).
For example if I have
class testClass
{
int t;
}
testClass tc = new testClass();
tc.t = 99;
And then I'm using it like:
aObj.DoSomething (tc);
I cannot be sure that the t value will not change, although I didn't use ref
or out keywords.
Of course I can copy the tc to another local variable and then sending the
copied object, but if testClass is a huge class, I will pay for it on run
time.