PDA

Click to See Complete Forum and Search --> : ref & out question


PT Exorcist
Sep 18th, 2003, 04:41 AM
let's see if i got it:
in c# ref types are by default passed by ref and value types are by default passed by out..is this truth?

Lethal
Sep 18th, 2003, 07:22 AM
By default, all parameters in .NET are passed by value (except reference types, which are always passed by ref. Output parameters are always passed by reference and do not need to be initialized before use. The method that is called is responsible for initializing the variable.

PT Exorcist
Sep 18th, 2003, 07:28 AM
hmm i didnt get it

what does "out" do? is it the ByVal equivalent to vb.net?

DevGrp
Sep 18th, 2003, 10:18 AM
When a parameter is passed using out, it does not have to be initialized. You can just declare it and pass it.

string name;

Hello(out name);

public viod Hello(out string Name)
{
Name = "DevGrp";
}

if out was'nt used you would get a compile error.

PT Exorcist
Sep 18th, 2003, 11:16 AM
ahhhhhhh!

and for what is it useful?!

Lethal
Sep 18th, 2003, 01:09 PM
If you want to create a method that returns multiple values

hellswraith
Sep 18th, 2003, 01:18 PM
Lethal, did you get a pm from me? Haven't heard a response, so I wasn't sure.

Lethal
Sep 18th, 2003, 01:27 PM
No, didn't get it. Let me check.

hellswraith
Sep 18th, 2003, 01:32 PM
It was just about the MCSD exams for .net, and whether you took any of the C# exams yet. If so, what should I hit hard on with my studying?

Lethal
Sep 18th, 2003, 01:35 PM
I'm going to take the windows exam here in the next few days. If it's anything like the old exams from the VB6 days, I'm gonna spend alittle extra time going over the different types of deployment and the various setup files.