Click here to Skip to main content
15,895,538 members
Home / Discussions / C#
   

C#

 
QuestionHebrew or Arabic string in TextBox - characters are reordered automatically for displaying Pin
wex_pl28-Aug-07 4:51
wex_pl28-Aug-07 4:51 
QuestionXmlTextReader Clean Up Pin
swjam28-Aug-07 4:48
swjam28-Aug-07 4:48 
AnswerRe: XmlTextReader Clean Up Pin
Scott Dorman28-Aug-07 5:05
professionalScott Dorman28-Aug-07 5:05 
QuestionVariable transfer between different .net Programs Pin
Der M28-Aug-07 4:29
Der M28-Aug-07 4:29 
AnswerRe: Variable transfer between different .net Programs Pin
led mike28-Aug-07 4:46
led mike28-Aug-07 4:46 
AnswerRe: Variable transfer between different .net Programs Pin
DavidNohejl28-Aug-07 5:44
DavidNohejl28-Aug-07 5:44 
GeneralRe: Variable transfer between different .net Programs Pin
Der M28-Aug-07 7:08
Der M28-Aug-07 7:08 
Questiondecimal values Pin
jon-8028-Aug-07 3:56
professionaljon-8028-Aug-07 3:56 
How would you suggest that I go about multiplications for decimal and double types since they are not allowed by VS2005?

I'm not sure why they are not allowed by Microsoft, but, is there some valid reason for that?

In the following snippet the code will break at the following line:
 _balance += _amount + (amount * 0.1);

Error:
Error	1	Operator '*' cannot be applied to operands of type 'decimal' and 'double'	

--------------------------------------------------------------------------------------------
Code:
using System;
using System.Collections.Generic;
using System.Text;
using Wrox.Interfaces;
using Wrox.Classes;

namespace Wrox.Interfaces 
{ public interface IBankAccount 
    { 
        void PayIn(decimal amount); 
        bool Withdraw(decimal amount); 
        decimal Balance 
            { get;} 
    } 
}

namespace Wrox.Classes
{
    public class VenusBankAccount : IBankAccount
    {
        public Exception InsufficientFunds;
        private decimal _balance;
                public void PayIn (decimal _amount) {
            _balance += _amount;
        }
        public bool Withdraw (decimal _amount) {
            if (_balance > _amount)
            { 
                _balance -= _amount;
                return true;
            }
            else
            { 
                throw InsufficientFunds;
            }
        }
        public decimal Balance {
            get
            {
                return _balance;
            }
        }

        public void PayInWithCommission (decimal _amount) {
            //Business rule: This method includes a 10% commission with the payin amount.
            _balance += _amount + (amount * 0.1);
        }
    }
}
namespace TestConsole
{

    class Program
    {
        static void Main(string[] args)
        {
            IBankAccount myFirstBankAccount = new VenusBankAccount();
            myFirstBankAccount.PayIn(1000);

            /* The following line will not execute because the myFirstBankAccount references IBankAccount,
               hence can implement properties and methods defined by IBankAccount interface.                */
            // myFirstBankAccount.PayInWithCommission;

            VenusBankAccount myRealVenusBankAccount = new VenusBankAccount();
            myRealVenusBankAccount.PayInWithCommission(1000);
        }
    }
}




Jon

AnswerRe: decimal values Pin
Colin Angus Mackay28-Aug-07 4:13
Colin Angus Mackay28-Aug-07 4:13 
AnswerRe: decimal values Pin
Scott Dorman28-Aug-07 4:15
professionalScott Dorman28-Aug-07 4:15 
GeneralRe: decimal values Pin
Colin Angus Mackay28-Aug-07 5:22
Colin Angus Mackay28-Aug-07 5:22 
GeneralRe: decimal values Pin
Scott Dorman28-Aug-07 7:12
professionalScott Dorman28-Aug-07 7:12 
QuestionCreating DLL's Pin
Dewald28-Aug-07 2:39
Dewald28-Aug-07 2:39 
AnswerRe: Creating DLL's Pin
led mike28-Aug-07 4:59
led mike28-Aug-07 4:59 
AnswerRe: Creating DLL's Pin
sthotakura28-Aug-07 5:26
sthotakura28-Aug-07 5:26 
QuestionThe "using" statements at the top of a .cs Pin
Vodstok28-Aug-07 2:32
Vodstok28-Aug-07 2:32 
AnswerRe: The "using" statements at the top of a .cs Pin
Martin#28-Aug-07 2:41
Martin#28-Aug-07 2:41 
GeneralRe: The "using" statements at the top of a .cs Pin
Vodstok28-Aug-07 2:46
Vodstok28-Aug-07 2:46 
AnswerRe: The "using" statements at the top of a .cs Pin
Spacix One28-Aug-07 2:42
Spacix One28-Aug-07 2:42 
GeneralRe: The "using" statements at the top of a .cs Pin
Scott Dorman28-Aug-07 4:19
professionalScott Dorman28-Aug-07 4:19 
GeneralRe: The "using" directives at the top of a .cs Pin
PIEBALDconsult28-Aug-07 6:58
mvePIEBALDconsult28-Aug-07 6:58 
GeneralRe: The "using" directives at the top of a .cs Pin
Scott Dorman28-Aug-07 7:00
professionalScott Dorman28-Aug-07 7:00 
AnswerRe: The "using" statements at the top of a .cs Pin
Mark Churchill28-Aug-07 3:11
Mark Churchill28-Aug-07 3:11 
AnswerRe: The "using" directives at the top of a .cs Pin
PIEBALDconsult28-Aug-07 6:36
mvePIEBALDconsult28-Aug-07 6:36 
GeneralRe: The "using" directives at the top of a .cs Pin
Scott Dorman28-Aug-07 7:16
professionalScott Dorman28-Aug-07 7:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.