0

I have a prototype:

 int[] medianFileter(int[] data);

and an array

 int[] intVal = new int[5];

How can I pass the intVal to the prototype in C#?

asked Jul 7, 2009 at 5:24
2
  • I don't understand how someone with 962 rep. and 2 silver badges ask such a simple question. Commented Jul 7, 2009 at 5:30
  • 1
    Because maybe his 964 (now) reputation points came from expertise in another programming language? This isn't a C# specific site. Commented Jul 7, 2009 at 6:00

4 Answers 4

7

Um, you just call it (assuming you've got a real implementation to call):

int[] result = medianFileter(intVal);

Note that any changes made to the array within the method will show up in intVal: you're not passing each of the integers individually, but a reference to the whole array.

(There could be some trickiness here due to your use of the word "prototype" - it's not standard C# terminology, so I'm not exactly sure what you mean. If you could clarify the question, that would help.)

On a side note, method names in .NET are usually Pascal-cased, so this should probably be:

int[] result = ApplyMedianFilter(intVal);
answered Jul 7, 2009 at 5:26

1 Comment

+1 for 'not passing each of the integers individually, but a reference to the whole array'
0

It's either I don't see some obvious weirdness here, or it's just usual function invocation:

int[] medianFiltered = medialFileter(intVal);
answered Jul 7, 2009 at 5:27

Comments

0

This is what you would do,

medianFileter(intVal);
answered Jul 7, 2009 at 5:27

Comments

0

What's the problem with:

medianFileter(intVal);

?

answered Jul 7, 2009 at 5:28

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.