0

i am new to visual c++.. I had a method in .h file something like this:

  public:
   void DoSomething();

Here i need to pass byte array as parameter and i need to implement it in .cpp file.. I am working on windows phone 8 for this i need to include visual c++ project of windows phone run time component. I need to use this method in c# class and pass the byte array from there. But i dont know how to declare a byte array method in c++. can any one please help me to find the solution.

2 Answers 2

3

In C++/CX, what you're using for a Runtime Component, the signature would look like this (assuming you have a ref class):

void DoSomething(const Platform::Array<uint8>^ something);

This could be called from C# directly by passing in a byte[].

Sign up to request clarification or add additional context in comments.

2 Comments

hi, it worked fine when i am calling from c# thank you. i want to call "Method1"(for example) method in "C" whose parameter should be byte array.I want to call this method from C++. how to pass the "something" parameter to method in C.
You should be able to use the Data and Length properties on Array to pass the contents along to some C code.
0
public:
   void DoSomething(Byte *);

Or

public:
   void DoSomething(unsigned char *);

for exemple.

6 Comments

thank you for ur answer.it gives only single byte as out paramter. but i need here byte array with ref.
I'm not sure to understand what you need. i can say that if you want a reference instead just replace * by & like this : DoSomething(unsigned char &);.
i would like to use this dosomething method in c# and pass byte array to it.. but when i am accessing this method in c# class it is excepting byte as out parameter but i want it to be byte array as in paramter..
Well, and does it change something when you declare DoSomething with a reference instead of a pointer like i said in my previous answer ?
no it throws an error as low level pointers does not work in the native code.
|

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.