AI智能
改变未来

C#加油站计费系统

namespace WindowsFormsApplication11{public partial class Form1 : Form{public Form1(){InitializeComponent();System.Collections.ArrayList rooms = new System.Collections.ArrayList();rooms.Add(new Room(\"93#\", 5));rooms.Add(new Room(\"95#\", 6));rooms.Add(new Room(\"97#\", 7));rooms.Add(new Room(\"99#\", 8));cbRoom.DataSource = rooms;cbRoom.DisplayMember = \"RoomType\";cbRoom.ValueMember = \"Price\";}public class Room{public string RoomType { get; set; }public decimal Price { get; set; }public Room(string type, decimal price){this.RoomType = type;this.Price = price;}}private void button1_Click(object sender, EventArgs e){int number = int.Parse(textBox2.Text);decimal price = (decimal)cbRoom.SelectedValue;decimal a = (decimal)number * price;textBox3.Text = a.ToString(\"c\");}}}
赞(0) 打赏
未经允许不得转载:爱站程序员基地 » C#加油站计费系统