This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.
Hi all,
I'm developing class library with C++.NET. I'm defining my enum as follows:
namespace
{
FUNC_OK, FUNC_FAIL, ........
FUNC_OK,
FUNC_FAIL,
........
};
ReturnCode^ FUNC1 ();
};}
public class User { public void CallF1() { myAPI api = new myAPI(); ReturnCodes rc = api.FUNC1(); ..... } }
public void CallF1() { myAPI api = new myAPI(); ReturnCodes rc = api.FUNC1(); ..... }
myAPI api = new myAPI(); ReturnCodes rc = api.FUNC1(); .....
I'm receiving compilation error:
Cannot implicitly convert type 'System.Enum' to 'myNameSpace.ReturnCode'. An explicit conversion exists (are you missing a cast?)
Compiler recognizes that type of value returned by FUNC1() is System.Enum, while it should be myNameSpace.ReturnCode.
What is wrong?
Thanks in advance,
Michael.
Change the C++/CLI function signature to:
ReturnCode FUNC1 (); //i.e., remove the 'hat'
The 'hat' is not generally used for value types. Both 'enum class' and 'enum struct' are value types in C++/CLI.
Thanks!
It has solved my issue!