Custom attribute : attribute « Class « Visual C++ .NET






Custom attribute

 
#include "stdafx.h"
using namespace System;

[AttributeUsageAttribute(AttributeTargets::All)]
public ref class OwnerAttribute : Attribute{
   public:
      property String^ DevOwner;
      property DateTime^ CreationDate;

      OwnerAttribute(){ }

      OwnerAttribute(String^ _DevOwner)
      {
         DevOwner = _DevOwner;
      }
};

[ Owner("Smith")]
ref class C1
{
};

[ Owner(DevOwner="Smith") ]
ref class C2
{
};

   
  








Related examples in the same category

1.Creating Custom attribute
2.Obsolete attribute
3.Out attribute parameter
4.Use the FlagsAttribute