How can I declare constant strings for use in both an unmanaged C++ dll and in a C# application?
- by Surfbutler
Curently I'm passing my const string values up from my C++ into my C# at startup via a callback, but I'm wondering if there's a way of defining them in a C++ header file that I can then also refer to in C#.
I already do this with enums as they are easy.
I include a file in both my C++ library project (via a .h file with a pragma once at the top), and my C# application (as a link):
#if _NET
public
#endif
enum ETestData
{
First,
Second
};
I know it sounds messy, but it works :)
But...how can I do the same with string constants - I'm initially thinking the syntax is too different between the platforms, but maybe there's a way?
Using clever syntax involving #if _NET, #defines etc?
Using resource files?
Using a C++/CLI library?
Any ideas?