-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFig-6.18 - MethodOverload.cs
More file actions
80 lines (66 loc) · 1.75 KB
/
Copy pathFig-6.18 - MethodOverload.cs
File metadata and controls
80 lines (66 loc) · 1.75 KB
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
// Fig. 6.18: MethodOverload.cs
// Usando métodos sobrecarregados.
using System;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
partial class MethodOverload : Form
{
private Button showOutputButton;
private Label outputLabel;
private void InitializeComponent()
{
this.showOutputButton = new Button();
this.outputLabel = new Label();
// showOutputButton.
this.showOutputButton.Name = "showOutputButton";
this.showOutputButton.Text = "Show Output";
this.showOutputButton.AutoSize = true;
this.showOutputButton.Location = new Point(10, 10);
this.showOutputButton.Click += new EventHandler(showOutputButton_Click);
// outputLabel.
this.outputLabel.Name = "outputLabel";
this.outputLabel.Text = "";
this.outputLabel.AutoSize = true;
this.outputLabel.Location = new Point(10, 40);
// MethodOverload.
this.Controls.AddRange(new Control[]{
this.showOutputButton, this.outputLabel
});
this.Name = "MethodOverload";
this.Text = "MethodOverload";
this.AutoSize = true;
this.ResumeLayout(false);
}
public int Square(int x)
{ return x * x; }
public double Square(double y)
{ return y * y; }
private void showOutputButton_Click(object? sender, EventArgs e)
{
outputLabel.Text =
"The square of integer 7 is " + Square(7) +
"\nThe square of double 7.5 is " + Square(7.5);
}
}
partial class MethodOverload
{
private Container? components = null;
public MethodOverload()
{ InitializeComponent(); }
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{ components.Dispose(); }
base.Dispose(disposing);
}
}
static class Program
{
[STAThread]
static void Main()
{
ApplicationConfiguration.Initialize();
Application.Run(new MethodOverload());
}
}