The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Why does C# require 'ref' and 'out' at both definition and use?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eric Gunnerson

Posts: 1006
Nickname: ericgu
Registered: Aug, 2003

Eric Gunnerson is a program manager on the Visual C# team
Why does C# require 'ref' and 'out' at both definition and use? Posted: Mar 1, 2004 6:28 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Eric Gunnerson.
Original Post: Why does C# require 'ref' and 'out' at both definition and use?
Feed Title: Eric Gunnerson's C# Compendium
Feed URL: /msdnerror.htm?aspxerrorpath=/ericgu/Rss.aspx
Feed Description: Eric comments on C#, programming and dotnet in general, and the aerodynamic characteristics of the red-nosed flying squirrel of the Lesser Antilles
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Eric Gunnerson
Latest Posts From Eric Gunnerson's C# Compendium

Advertisement

(question from a customer)

If you use 'ref' or 'out' on a method parameter:

class Test
{
    public void Process(ref int t)
    {
        ...
    }
}

when you call it you need to specify 'ref':

Test t = new Test();
int val = 5;

t.Process(ref val);

We require you to include 'ref' or 'out' to improve the readability of your code. Anybody who looks at the call above can tell that the value of val might be changed during the call. Otherwise, you'd have to find the definition, which would be much more difficult.

Read: Why does C# require 'ref' and 'out' at both definition and use?

Topic: Your program as ShellExtension (Registry) - Including Resources Previous Topic   Next Topic Topic: Counterstrike: Condition Zero Hits Shelves on 3/23/03

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use