If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Here the tryparse method returns a bool: true if the parsing was successful, otherwise false. If parsing was successful, the value is stored in the risk variable (which you passed as an out parameter). If parsing isn't successful, the risk variable has some undefined value (but you're going to handle the error anyway, so you can make some intelligent choice).

Hope that helps!

Best Regards,

BioPhysEngrhttp://blog.biophysengr.net
--
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Re: how to parse a text box to an integer - but....

Just wanted to say thanks for the help. Your response prompted me to look more into arrays. And.. After figuring them out and applying them what I was doing, it turns out I didn't need to do any of the things my original post asked about.

Here the tryparse method returns a bool: true if the parsing was successful, otherwise false. If parsing was successful, the value is stored in the risk variable (which you passed as an out parameter). If parsing isn't successful, the risk variable has some undefined value (but you're going to handle the error anyway, so you can make some intelligent choice).

Hope that helps!

I don't see the reasoning behind using a List<T> here unless he is going to add more controls dynamically to this list that he wants to use to replace R1_ with... That is unnecessary. For textbox input though, you should always use TryParse().

spinn, how are you deciding whether R2_ or R3_ replaces R1_? At random or?

Re: how to parse a text box to an integer - but....

That whole article is based on the rant for why Eric doesn't need arrays in his programming venture's for the most part, and under specific circumstances. It doesn't mean that they should never be used because they do offer performance gains over other collection types, when the functionality of one over the other is not required by the design of the application itself.

"Parallelism Problems" and:

Arrays make optimizing for things like “swapping two values” easy, but destroy the larger ability to optimize for parallelism.

However, we're not working with Parallel anything here as far as I know...

Jon Skeet said:

Really just answering to add a link which I'm surprised hasn't been mentioned yet: Eric's Lippert's blog entry on "Arrays considered somewhat harmful."

You can judge from the title that it's suggesting using collections wherever practical - but as Marc rightly points out, there are plenty of places where an array really is the only practical solution.

As I said though, we are not needing to resize this array, so no expense there. In fact, we don't even have to use an array or a collection for this if it's only these 3 controls, why would you?

Here was a reasonable guide I seen on the differences:

Use an array when you are dealing with data that is:

• fixed in size, or unlikely to grow much
• suitably large (more than 10, 50, 100 elements, depending on the algorithm)
• you will be doing lots of indexing into it, i.e. you know you will often want the third element, or the fifth, or whatever.

Use a list for:

• variable length data lists
• that are mostly used as a stack or a queue or need to be iterated in its entirety
• when you do not want to write an expression to derive the ultimate array size for the declaration and you do not want to wastefully pick a large number

The performance of an array is good. Here's a comment:

That said, I make a lot of use of arrays in my protobuf-net project; entirely for performance

List<T> here offers a lot more functionality that we don't even need, there's no need for it. He's cautioning not to use an array because he believes most beginner programmers (what the topic was instigated from), would not understand how they should be used effectively, and a collection based type would help make things easier on that front.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.