What you see is called "Directional Attributes"
FileStream.Read([In, Out] byte[]....)
If you observe the [In, Out] is an attribute that has been applied to a
parameter. And as a user you don't have to explicitly mention this when you
use the API.
Directional attributes are optional. Some languages provide keywords that
enable you to modify the directional flow of method parameters. So the
"out" & "ref" you see in C# are just keywords in that lanugage.
Search for "Directional Attributes" in Visual Studio help or MSDN for more
details.
--------------------
From: "Gene" <go******@intellireach.com.no spam>
Subject: byte array as an argument has "implicit" ref behavior?
Date: Mon, 17 Nov 2003 10:39:00 -0500
Lines: 28
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <eW**************@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: 65.215.3.2
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:199874
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
I'm not sure I understand this behavior (at least in the context of C#).
I understand the use of "ref" and "out" keywords as they apply to method
arguments, and then something this morning stopped me in my tracks. I must
have used FileStream.Read a thousand times and it never dawned on me that I
never have to specify either an "out" or "ref" when I pass the byte array
that I pass to this function- yet it returns the bytes read from the file.
The documentation (msdn) further confused me because they show an "in"
keyword as part of the method definition... how does "in" fit into this?
[C#]
public override int Read(
in byte[] array,
int offset,
int count
);
In C++ arrays and structures are "passed" by pointer- is this what C# is
doing for me? I haven't defined a struct and tried this either- what
exactlyam I looking at?
Thanks in advance,
Gene
Rakesh, EFT.
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm