Click here to Skip to main content
15,896,726 members
Home / Discussions / C#
   

C#

 
AnswerRe: help Pin
#realJSOP17-Dec-11 3:04
professional#realJSOP17-Dec-11 3:04 
GeneralReason for my vote of 1 Pin
Manfred Rudolf Bihy17-Dec-11 15:21
professionalManfred Rudolf Bihy17-Dec-11 15:21 
GeneralRe: Reason for my vote of 1 PinPopular
#realJSOP18-Dec-11 0:57
professional#realJSOP18-Dec-11 0:57 
AnswerRe: help Pin
AmitGajjar17-Dec-11 7:22
professionalAmitGajjar17-Dec-11 7:22 
Questionunmanaged - returning arrays Pin
Mark H Bishop16-Dec-11 12:26
Mark H Bishop16-Dec-11 12:26 
AnswerRe: unmanaged - returning arrays Pin
Luc Pattyn16-Dec-11 15:08
sitebuilderLuc Pattyn16-Dec-11 15:08 
GeneralRe: unmanaged - returning arrays Pin
Mark H Bishop17-Dec-11 4:08
Mark H Bishop17-Dec-11 4:08 
GeneralRe: unmanaged - returning arrays Pin
Luc Pattyn17-Dec-11 4:22
sitebuilderLuc Pattyn17-Dec-11 4:22 
You're right, there's a typo in my article, nobody ever noticed, myself including. I will fix it.
int sum=SumArray(numbers, dim); is what it should be in automatic mode.
Thanks for pointing this out.

Your code is fine. One suggestion: whenever possible, also pass the length as a separate parameter, that way your native code can be confident about how much data it can safely read and/or write (automatic mode turns the array reference into a simple pointer, so all size info isn't passed on). That is what the dim parameter is doing in my example. As always, reading memory locations you're not supposed to read may cause an exception, writing beyond the boundaries most probably will cause an exception.

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

GeneralRe: unmanaged - returning arrays Pin
Mark H Bishop17-Dec-11 7:22
Mark H Bishop17-Dec-11 7:22 
AnswerRe: unmanaged - returning arrays Pin
Luc Pattyn17-Dec-11 7:40
sitebuilderLuc Pattyn17-Dec-11 7:40 
GeneralRe: unmanaged - returning arrays Pin
harold aptroot17-Dec-11 5:13
harold aptroot17-Dec-11 5:13 
GeneralRe: unmanaged - returning arrays Pin
Mark H Bishop17-Dec-11 7:16
Mark H Bishop17-Dec-11 7:16 
GeneralRe: unmanaged - returning arrays Pin
Mark H Bishop17-Dec-11 7:29
Mark H Bishop17-Dec-11 7:29 
QuestionCoolest way to do this string operation? Pin
SledgeHammer0116-Dec-11 11:23
SledgeHammer0116-Dec-11 11:23 
AnswerRe: Coolest way to do this string operation? Pin
PIEBALDconsult16-Dec-11 11:34
mvePIEBALDconsult16-Dec-11 11:34 
GeneralRe: Coolest way to do this string operation? Pin
SledgeHammer0116-Dec-11 11:44
SledgeHammer0116-Dec-11 11:44 
GeneralRe: Coolest way to do this string operation? Pin
PIEBALDconsult16-Dec-11 11:52
mvePIEBALDconsult16-Dec-11 11:52 
GeneralRe: Coolest way to do this string operation? Pin
SledgeHammer0116-Dec-11 12:06
SledgeHammer0116-Dec-11 12:06 
GeneralRe: Coolest way to do this string operation? Pin
Not Active16-Dec-11 13:54
mentorNot Active16-Dec-11 13:54 
AnswerRe: Coolest way to do this string operation? Pin
AspDotNetDev16-Dec-11 11:50
protectorAspDotNetDev16-Dec-11 11:50 
GeneralRe: Coolest way to do this string operation? Pin
PIEBALDconsult16-Dec-11 11:57
mvePIEBALDconsult16-Dec-11 11:57 
AnswerRe: Coolest way to do this string operation? Pin
AspDotNetDev16-Dec-11 12:05
protectorAspDotNetDev16-Dec-11 12:05 
AnswerRe: Coolest way to do this string operation? Pin
harold aptroot16-Dec-11 12:16
harold aptroot16-Dec-11 12:16 
GeneralRe: Coolest way to do this string operation? Pin
AspDotNetDev16-Dec-11 12:25
protectorAspDotNetDev16-Dec-11 12:25 
GeneralRe: Coolest way to do this string operation? Pin
harold aptroot16-Dec-11 12:37
harold aptroot16-Dec-11 12:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.