473,398 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Difference between out and [Out]

I have been doing a lot of PInvoke calls using signatures published on
www.pinvoke.net. I notice that where out parameters are involved, sometimes
the signature uses 'out' and sometimes '[Out]'. I have discovered that using
the wrong one causes nasty things to happen, but I can't work out what the
difference is, and when one should be used and when the other (luckily I have
not yet had to work out my own signatures for PInvoke calls, but I may have
to one day)
--
Dave
Nov 4 '07 #1
4 1181
>I have been doing a lot of PInvoke calls using signatures published on
>www.pinvoke.net. I notice that where out parameters are involved, sometimes
the signature uses 'out' and sometimes '[Out]'. I have discovered that using
the wrong one causes nasty things to happen, but I can't work out what the
difference is, and when one should be used and when the other (luckily I have
not yet had to work out my own signatures for PInvoke calls, but I may have
to one day)
out is equivalent to using [Out] ref.

Both ref and out change the way the parameter is passed (by reference
ratehr than by value).
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 4 '07 #2
Thanks. I understand out and ref. Can you explain what [Out] actually is,
syntactically?
--
Dave
"Mattias Sjögren" wrote:
I have been doing a lot of PInvoke calls using signatures published on
www.pinvoke.net. I notice that where out parameters are involved, sometimes
the signature uses 'out' and sometimes '[Out]'. I have discovered that using
the wrong one causes nasty things to happen, but I can't work out what the
difference is, and when one should be used and when the other (luckily I have
not yet had to work out my own signatures for PInvoke calls, but I may have
to one day)

out is equivalent to using [Out] ref.

Both ref and out change the way the parameter is passed (by reference
ratehr than by value).
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 14 '07 #3
On Nov 14, 9:03 am, Dave <D...@discussions.microsoft.comwrote:
Thanks. I understand out and ref. Can you explain what [Out] actually is,
syntactically?
It's an attribute - OutAttribute, to be specific.

Jon

Nov 14 '07 #4
Doh! Of course it is. Sorry. Attributes are one aspect of the C# language
I've never really got my head round, I must read up on them more carefully.
Thanks for the quick response.
--
Dave
"Jon Skeet [C# MVP]" wrote:
On Nov 14, 9:03 am, Dave <D...@discussions.microsoft.comwrote:
Thanks. I understand out and ref. Can you explain what [Out] actually is,
syntactically?

It's an attribute - OutAttribute, to be specific.

Jon

Nov 14 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
by: yensao | last post by:
Hi, I have a hard time to understand difference and similarities between Relational database model and the Object-Oriented model. Can somebody help me with this? Thank you in advance. ...
9
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just...
26
by: yensao | last post by:
Hi, I have a hard time to understand difference and similarities between Relational database model and the Object-Oriented model. Can somebody help me with this? Thank you in advance. ...
15
by: student4lifer | last post by:
Hello, I have 2 time fields dynamically generated in format "m/d/y H:m". Could someone show me a good function to calculate the time interval difference in minutes? I played with strtotime() but...
11
by: cmb3587 | last post by:
I have two arrays and I'm trying to create a 3rd array that is the difference between the two arrays Ex: arrayA: 3 5 8 9 arrayB: 3 4 6 9 difference of A-B: 5 8 however, my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.