Created
August 21, 2020 07:12
-
-
Save jindeveloper/09a7c46b6104437eb92a567fa19e338d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace CSharp_Attributes_Walkthrough.My_Custom_Attributes | |
| { | |
| /// <summary> | |
| /// This class is a custom attribute class. | |
| /// Moreover, it is using the AttributeUsage attribute to annotate | |
| /// that this attribute is applicable only to class, struct and property. | |
| /// </summary> | |
| [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property)] | |
| public class AliasAttribute : Attribute | |
| { | |
| /// <summary> | |
| /// These parameters will become mandatory once have you decided to use this attribute. | |
| /// </summary> | |
| /// <param name="alias"></param> | |
| /// <param name="color"></param> | |
| public AliasAttribute(string alias, ConsoleColor color) | |
| { | |
| this.Alias = alias; | |
| this.Color = color; | |
| } | |
| #region Positional-Parameters | |
| public string Alias { get; private set; } | |
| public ConsoleColor Color { get; private set; } | |
| #endregion | |
| //Added an optional-parameter | |
| public string AlternativeName { get; set; } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment