Pass byte array to not static function in class

I have to send a byte array to class (class take care about all communication with FTDI) . Unfortunately I can't use static function to do that
 public static void st_SendCommand(ref byte[p,int iSize) will not work because of FTDI dll restrictions. I resolved this situation in other cases when it wasn't array as argument by calling not static function from static and it works. But it is not working with array. I need to send array and size of array to my class  and it those parameters have to be used in some not static function.
How can I do that?
Who is Participating?
What problem appear when you use array with "ref"?
There is no name of variable  in your code
public static void st_SendCommand(ref byte[p,int iSize)

Open in new window

It must be
public static void st_SendCommand(ref byte[] ArrayName,int iSize);

Open in new window

When you call this method, you should use this construction:
st_SendCommand(ref ArrayName, iSize);

Open in new window

If you use "ref" you should initialize this variale, and then pass it to the method.
If you use "out" instead of "ref". You can not initialize  this, but you should do it in your method before using.
May be you should create property in your class and initialize  this property (array) in constructor?
But I haven't understood what problems with "ref" yet.
AndyAinscowFreelance programmer / ConsultantCommented:
It should work without problem.  Basically put the static keyword means that you do not need to create a separate object of that type which is distinct from a second object of the same type.  The static 'shares' the function.

Put another way.
Anything like
public static XXX foo(params) can also be coded as public XXX foo(params).  There is no restriction on the type of variables you use in params.
mastiSoftAuthor Commented:
Thank you very much for your help.
Glad to help you!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.