WindowsFormsApplication2.Form1.BankAccount
不包含 for 的定义,也找不到接受第一个类型参数的withBox
扩展方法(您是否缺少 using 指令或程序集引用?)withBox
WindowsFormsApplication2.Form1.BankAccount
这是num1 = Convert.ToDecimal(this.withBox.Text);
代码行之一。
早些时候我问了一个关于这个的问题,并对我的问题做了更多的研究。我相信这次我做的一切都是正确的。但仍然出现错误。我不确定我现在做错了什么。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
BankAccount a = new BankAccount();
public Form1()
{
InitializeComponent();
decimal iBa = 300.00m;
this.aMtBox.Text = iBa.ToString();
}
private void dep_Click(object sender, EventArgs e)
{
try
{
decimal num1 = 0.00m;
decimal iBa = 300.00m;
num1 = Convert.ToDecimal(this.depBox.Text);
decimal total = num1 + iBa;
this.aMtBox.Text = total.ToString();
}
catch
{
MessageBox.Show("ERROR", "Oops, this isn't good!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
public void withdrawl_Click(object sender, EventArgs e)
{
this.aMtBox.Text = a.Balance.ToString();
}
public class BankAccount
{
decimal balance;
decimal iBa;
decimal num1;
public decimal Balance
{
get {return balance;}
}
public decimal IBa
{
get {return iBa;}
}
public decimal Num1
{
get {return num1;}
}
public BankAccount()
{
iBa = 300.00m;
num1 = Convert.ToDecimal(this.withBox.Text);
balance = iBa - num1;
}
}
}
}