/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
samples/snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source2.cpp
41 строка
731 B
Andy De George
Move snippets from samples repo to this repo (#17296)
03 мар 2020, 19:23
Не верифицирован
03 мар 2020, 19:23
dbbeda1
Код
Авторство
О чём код?
// <snippet2> using namespace System; public ref class ExampleAttribute : Attribute { private: String^ stringVal; public: ExampleAttribute() { stringVal = "This is the default string."; } property String^ StringValue { String^ get() { return stringVal; } void set(String^ value) { stringVal = value; } } }; [Example(StringValue="This is a string.")] public ref class Class1 { public: static void Main() { System::Reflection::MemberInfo^ info = Type::GetType("Class1"); for each (Object^ attrib in info->GetCustomAttributes(true)) { Console::WriteLine(attrib); } } }; int main() { Class1::Main(); } // </snippet2>