-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptionalParameters.cs
More file actions
42 lines (37 loc) · 1021 Bytes
/
Copy pathOptionalParameters.cs
File metadata and controls
42 lines (37 loc) · 1021 Bytes
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OptionalParameters
{
class Program
{
static void Main(string[] args)
{
student("Dilshod", "Sadiev");
Console.WriteLine($"Graduation year: {add(2012, 3)}" );
Console.ReadLine();
}
// Overload method with no arguments
static void student()
{
Console.WriteLine("No data");
}
// Overload with a argument
static void student(string firstName)
{
Console.WriteLine($"First name: {firstName}");
}
// Overload with two arguments
static void student(string firstName, string lastName)
{
Console.WriteLine($"First name: {firstName}\nLast Name: {lastName}");
}
//method with default parameters
static int add(int a=0, int b=0)
{
return a+b;
}
}
}