0
 using System;
 using System.Collections.Generic;
 using System.Text;

 namespace Bank
{
public class Overdraft : Account
{
    double credit;
    double inter = 0.15;
    public double Credit
    {
        get { return credit; }
    }
    public Overdraft()
    {

    }
    public Overdraft(String acno, String nam, double amt, double cred)
        : base(acno, nam, amt)
    {
        this.credit = cred;
    }
    public override bool deposit(double amount)
    {
        amt += amount;
        return true;
    }

    public override bool withdraw(double amount)
    {
        if (amount <= (credit + amt))
        {
            amt -= amount;

            if (amt < 0)
            {
                credit -= Math.Abs(amt);
                due = Math.Abs(amt);
                interest();
            }
            return true;
        }

        else
            Console.WriteLine("\n!!!!Credit Limit Crossed!!!!");
        return false;
    }

    public void interest()
    {
        due = due * inter;
        Console.WriteLine("The Interest for due amount is Rs. {0}", due);
        return true;
    }

     public override string ToString()
    {
        return string.Format("Account Details: \nACC NO = {0} \nName = {1} \nBalance = Rs. {2}\nCredit =Rs. {3} \n", accno, name, amt, credit);
    }

}

}

The above is one of the class in dll of my code. The question is how should i pass those Console.Writeln statements in Windows Forms and also ToString method. Or anyone can tell me how to get those statement in forms in a messagebox.

4

1 回答 1

0

不要Console.WriteLine在你的 dll 中使用。您在 UI (WinForms) 中的客户端代码应检查布尔返回值/调用ToString()并向用户提供相关信息。

PS。考虑将双精度数更改为小数以存储金额。

于 2013-04-24T10:30:25.433 回答