allow you to add declarative information to your program. / a class that inherits from System.Attribute base class
pre-defined attributes - .NET framework
- Obsolete : Marks types and type members outdated
- WebMethod : To expose a method as an XML Web service method
- Serializable : Indicates that a class can be serialized
using System;
using System.Collections.Generic;
public class Program
{
private static void Main(string[] args)
{
//Calculator.Add(10, 20 ); //as of true of parameter
Calculator.Add(new List<int>(){10, 20});
}
}
public class Calculator
{
[Obsolete("Use Add(List<int> Numbers) Method", true)] //attributes
public static int Add(int FN, int SN)
{
return FN + SN;
}
public static int Add(List<int> Numbers)
{
int Sum = 0;
foreach (int Number in Numbers)
{
Sum += Number;
}
return Sum;
}
}