Re: Return array from method
Quote:
Originally Posted by Westerberg
Is it possible to pass an array from a method?
Code:
yourType[] function()
{
// create array
yourType[] arr = ...;
// return array
return arr;
}
- petter
Re: Return array from method
Re: Return array from method
Well there is the other way, but it`s used in a little diferrent situation that you describes. You can use it to send an array to function to change it and have it back
Code:
void SomeFunc(out type [] array)
{
//some actions with array
}
Re: Return array from method
noooooo.. dont tell people that when they havent got the basics understood.. :)
out and ref parameter modifiers should be left well alone until the developer knows the difference between the stack and the heap
Re: Return array from method
Its true, I am working on the basics but I did find the out and ref parameter modifiers while searching. I'm using the code that wildfrog showed me since it works and a problem hasn't come up with it.
Re: Return array from method
Quote:
Originally Posted by cjard
noooooo.. dont tell people that when they havent got the basics understood.. :)
out and ref parameter modifiers should be left well alone until the developer knows the difference between the stack and the heap
Why not, we always need to learn smth new :rolleyes:
And as for me the basics are heap, stack reference and other things that are principal to programming language. What was nice in C all of this was easy to understand during first applications and in c# you may not see them but often use