Home > Net >  C # form programming
C # form programming

Time:04-15

Want to use Windows forms application
The custom class implements a simple + - */
With the if (the Convert. ToString (proID)=="+")
Form page with combox custom edit + - */
When selecting + input string of incorrect
How should solve?? Solving the brackets is a code was food judgment

Private void button1_Click (object sender, EventArgs e)
Try
{


Int myid=the Convert. ToInt32 (textBox1. Text);
String myName=textBox2. Text;
Int myProID=the Convert. ToInt32 (comboBox1. Text);

JHInfo p1=new JHInfo (myid, myName, myProID);
P1. Showinfo ();
}
The catch (Exception ex)
{
MessageBox. Show (ex. Message);
}

Working class Goods
{
Public int id;
Public string Name;
Public Goods (int, string n)
{
Id=1;
Name=n;
(class JHInfo: Goods
{
Private int proID.
Public int ProID
{
The set {proID=value; }
}

Public JHInfo (int id2, string Name2, int proID2)
: base (id2, Name2)
{
ProID=proID2;

}
Public void showinfo ()
{
String pro;
If (the Convert. ToString (proID)=="+")
{
Pro="food";
}
Else if (proID==1)
{
Pro="drug";
}
The else
{
Pro="illegal products";
}
MessageBox. Show (" product id "+ id. The ToString () +", commodity Name "+ Name +", commodity classification "+ pro);
}
}
)
  •  Tags:  
  • C#
  • Related