-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOverloading.cs
108 lines (78 loc) · 2.97 KB
/
Overloading.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
• "FUNCTIONS" •
───────────────
• "OVERLOADING" •
▬ "Overloading" in "C#"
→ is the "Ability"
→ to Define "Multiple Methods"
→ with the "Same Name"
→ in a "Class",
→ but with "Different Signatures".
♦ A "Method's Signature"
→ is "Determined"
→ by the "Method's Name"
→ and its "List" of "Parameters",
→ "Including" their "Types"
→ and How they are "Passed"
→ (such as "Value", "Reference", or "Out").
▬ When a "Method"
→ is "Overloaded",
→ the "Compiler"
→ can "Distinguish" between these "Methods"
→ "Based" on their "Signatures"
→ so that It can "Call"
→ the "Correct Method"
→ "Based" on the "Arguments Received"
→ in a "Specific Method Call".
▬ By "Overloading",
→ we can "Create Methods"
→ with the "Same Name"
→ that Provide "Similar Functionality"
→ but Accept "Different Data Types"
→ or Different "Number" of "Arguments".
♦ This "Leads"
→ to "Greater Flexibility"
→ in the "Design"
→ and "Use" of "Classes"
→ and Methods in "C#".
▬ By "Overloading"
→ we "Use" the "Concept"
→ of "Polymorphism",
→ which means "More"
→ than "One Form".
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀*/
namespace Csharp.functions;
public class Overloading
{
// ▬ "Base Method"
// → without "Parameters" ▬
void Example()
{
}
// ▬ 1- "Overloading"
// → with a "Int Types" ▬
void Example(int number)
{
}
// ▬ 2- "Overloading"
// → with "2 Int Types" ▬
void Example(int number1, int number2)
{
}
// ▬ 3- "Overloading"
// → with "String Types" ▬
void Example(string word1, string word2)
{
}
// ▬ 4- "Overloading"
// → by using "Different Types" ▬
void Example(string word, int number)
{
}
// ▬ 4- "Overloading"
// → by "Changing" the "Order"
// → of the "Parameters" ▬
void Example(int number, string word)
{
}
}