.NET CLI
A cross-platform toolchain for developing, building, running, and publishing .NET applications.
322 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
in .net languages a class can have "attributes"... I have one, that has this attribute
[System::Runtime::InteropServices::GuidAttribute("7F7CD0DB-91EF-49dc-9FA9-02D128515DD4")]
... I need this value in my code. How can I access it in the C++/CLI language? MyClass[GuidAttribute]? MyClass:GuidAttribute? [GuidAttribute]MyClass? how is the syntax? ... I've no idea...
Rudolf
Check an idea:
[System::Runtime::InteropServices::GuidAttribute("7F7CD0DB-91EF-49dc-9FA9-02D128515DD4")]
ref class MyClass1
{
};
. . .
using namespace System::Runtime::InteropServices;
auto type = MyClass1::typeid; // or 'obj->GetType( )' if you have an object
auto attribututes = type->GetCustomAttributes( GuidAttribute::typeid, false);
if( attribututes->Length > 0)
{
auto attribute = (GuidAttribute^)attribututes[0];
String^ guid = attribute->Value;
// the Guid attribute was found
}