-
Notifications
You must be signed in to change notification settings - Fork 0
/
Attributes.cs
44 lines (36 loc) · 1.04 KB
/
Attributes.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Attributes allow you to add declarative information to your programs. This information can then be queried at runtime using reflection.
// 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 MainClass
{
private static void Main()
{
// List<int> listInt = new List<int>();
// listInt.Add(10);
// listInt.Add(20);
// listInt.Add(30);
Calculator.Add(10, 20);
Calculator.Add(new List<int>(){10,20,30});
}
}
public class Calculator
{
[Obsolete("This method is obsolete",false)]
public static int Add(int first, int second)
{
return first + second;
}
public static int Add(List<int> numbers)
// public static int Add(params int[] numbers)
{
int sum = 0;
foreach (int number in numbers)
{
sum = sum + number;
}
return sum;
}
}