CNSA-212-Personal/Chapter 5/Form1.cs

50 lines
1.4 KiB
C#
Raw Normal View History

2024-02-05 18:06:59 -05:00
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;
2024-02-05 22:30:11 -05:00
using System.Windows.Forms;using System;
using System.Collections.Generic;
2024-02-05 18:06:59 -05:00
using System.Windows.Forms;
2024-02-05 22:30:11 -05:00
2024-02-05 18:06:59 -05:00
namespace Chapter_5
{
public partial class Form1 : Form
{
2024-02-05 22:30:11 -05:00
2024-02-05 18:06:59 -05:00
public Form1()
{
InitializeComponent();
}
2024-02-05 22:30:11 -05:00
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);
}
2024-02-05 18:06:59 -05:00
}
}