locked
multiple try catch & int.tryparse RRS feed

  • Question

  • User379720387 posted

    I am having difficulty convincing VS that what I am trying to do is perfectly acceptable.

    The problem originates with data uncertainty and an elaborate contraption to figure out what data was received on how it needs to manipulated. Basically running it through a sieve

    The test data is designed to meet condition 1b2.

    The  int.tryparse fails and the code ends up where I have shown the arrow.

    I am thinking:

    1. at that point it should finish the condition 1b1 block

    2. and head for the else block 1b2.

    I can see VS hitting the closing } for 1b1 (where the arrow is), it should now hit the else branch

    test condition 1
      try...
        if condition 1a
          ...
        if condition 1b1
          try.Parse
    if true
    ...
    ==> else condition 1b2 ... catch test condition 2 more of the above with several try catch constructs

    Instead it skips all of that and ends at test condition 2.

    Like that else isn't even there.

    Tuesday, January 6, 2015 11:34 PM

Answers

  • User-1716253493 posted

    If im not wrong undertand your question

    int.tryparse is always success for parent try cacth

    try - cacth is always success for parent try catch

    to make fail use int.parse

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 7, 2015 3:11 AM