50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Forms;
|
|
|
|
|
|
namespace Chapter_5
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
private List<string> friendNames = new List<string>();
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
string input = "";
|
|
do
|
|
{
|
|
input = Microsoft.VisualBasic.Interaction.InputBox(
|
|
"Please enter a friend's name, then press ENTER" + Environment.NewLine + "(Enter -99 to stop input)",
|
|
"Input", "John Doe", 100, 100);
|
|
|
|
if(input != "-99")
|
|
{
|
|
friendNames.Add(input);
|
|
}
|
|
}
|
|
while (input != "-99");
|
|
|
|
ShowFriendNames();
|
|
}
|
|
|
|
private void ShowFriendNames()
|
|
{
|
|
string names = string.Join(Environment.NewLine, friendNames);
|
|
MessageBox.Show("Here are your friends:" + Environment.NewLine + names, "Friends List", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
}
|
|
} |