O'Reilly Forums: Page 90 Second Edition - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Page 90 Second Edition int inside () and one other questions on same page

#1 User is offline   shriner11 

  • New Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 01-August 12

Posted 01 August 2012 - 07:44 AM

Hi everyone. I am going through the book, still in the begining

Few questions on code on page 90 (step 3)

1) Why do we have int inside parenthesis? I tried not to put them and the code didn't work what's the significance?

2) Why do we get the legth of the code? len is just a variable, you could write "c" instead of len and the code would work? textbox1.text I thought stands for the text in the textbox not it's length.
0

#2 User is offline   shriner11 

  • New Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 01-August 12

Posted 01 August 2012 - 09:36 AM

View Postshriner11, on 01 August 2012 - 07:44 AM, said:

Hi everyone. I am going through the book, still in the begining

Few questions on code on page 90 (step 3)

1) Why do we have int inside parenthesis? I tried not to put them and the code didn't work what's the significance?

2) Why do we get the legth of the code? len is just a variable, you could write "c" instead of len and the code would work? textbox1.text I thought stands for the text in the textbox not it's length.



I figured out where the length is coming from, it's from the BlahBlahBlah() return statement. So that second point in my post is resolved. The first one's still open.
0

#3 User is offline   mmcanelly 

  • New Member
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 16-July 12

Posted 03 August 2012 - 09:56 PM

View Postshriner11, on 01 August 2012 - 09:36 AM, said:

I figured out where the length is coming from, it's from the BlahBlahBlah() return statement. So that second point in my post is resolved. The first one's still open.


The answer to the (int) question comes about 40 pages later. It's called "casting." Since the Value property returns a decimal, and your BlahBlahBlah method needs an int to work property, doing (int)numericUpDown1.Value will convert the decimal value to an int so that your BlahBlahBlah method can use it.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users