Reputation: 719
This is the first problem I have encountered. Truly, I don't know why this is. I read on it a bit and made most of what I saw important public (if not all). So I thought maybe someone here can explain this. Also, I am trying to make it where when someone types in the withdrawl text box and clicked on it, the aMtBox will show such amount. Is this workable? Or am I doing something very wrong here
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();
}
public void withdrawl_Click(object sender, EventArgs e)
{
MessageBox.Show("The balace is... {0:c2}", 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 = 0.00m;
balance = iBa - num1;
}
}
}
}
Upvotes: 2
Views: 2368
Reputation: 30728
change
a.balance.ToString()
to
a.Balance.ToString()
a.balance is inaccessible to outer class due to being private.
Upvotes: 3