Kevin Read
Kevin Read

Reputation: 37

Simple C# Beginner Question

I am trying to make a simple calculator. I am getting blue line under my numbers with the error "Method Name Expected"

I was hopeing you guys could help me out with my simple question from a noob.

finalCmb = .25(1.3(txtAtt.Text+txtStr.Text)+txtDef.Text+txtHp.Text+(.5(txtPray.Text))+(.5(txtSum.Text)));

Upvotes: 1

Views: 168

Answers (4)

Matt Hudson
Matt Hudson

Reputation: 7358

finalCmb = .25 * (1.3 * ((double)txtAtt.Text + (double)txtStr.Text)+(double)txtDef.Text+ (double)txtHp.Text+ (.5 * ((double)txtPray.Text)) + (.5 * ((double)txtSum.Text)));

Upvotes: -1

user142162
user142162

Reputation:

  1. You have to manually place multiplication operators. There is no bracket multiplication.

    25(1.3(te... should be 25 * (1.3 * (te...

  2. Converting strings to numbers would be a good idea.

    txtStr.Text to Double.Parse(txtStr.Text)

Upvotes: 8

Ed Swangren
Ed Swangren

Reputation: 124800

Your syntax is wrong. The compiler thinks that you are trying to call a method due to the opening parentheses when you do this

.25(1.3 ...

I'm not sure what you are actually trying to accomplish with that, but it doesn't make sense. I would suggest spending some more time learning the basics.

Upvotes: 0

rcravens
rcravens

Reputation: 8388

You need to put the asterisk symbol for multiplication.

Upvotes: 1

Related Questions