Results 1 to 10 of 10

Thread: ref & out question

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    ref & out question

    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?
    \m/\m/

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    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.

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    hmm i didnt get it

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

  4. #4
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    When a parameter is passed using out, it does not have to be initialized. You can just declare it and pass it.
    Code:
    string name;
    
    Hello(out name);
    
    public viod Hello(out string Name)
    {
         Name = "DevGrp";
    }
    if out was'nt used you would get a compile error.
    Last edited by DevGrp; Sep 18th, 2003 at 10:55 AM.

  5. #5

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    ahhhhhhh!

    and for what is it useful?!
    \m/\m/

  6. #6
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    If you want to create a method that returns multiple values

  7. #7
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Lethal, did you get a pm from me? Haven't heard a response, so I wasn't sure.

  8. #8
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    No, didn't get it. Let me check.

  9. #9
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    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?

  10. #10
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width