Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Powering through statements

Powering through statements

Scheduled Pinned Locked Moved C#
question
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Adam Turner
    wrote on last edited by
    #1

    Basically, i dont care if a set of statements throws an exception but i dont want the program flow to be interupted. How can i do this? Something like the following: int[] manyInts = new int[4]; manyInts[0] = 1; manyInts[1] = 1; manyInts[2] = 1; manyInts[3] = 1; manyInts[4] = 1; manyInts[5] = 1; So basically it executes every statement whether it thows an exception or not. -- ABT

    J 1 Reply Last reply
    0
    • A Adam Turner

      Basically, i dont care if a set of statements throws an exception but i dont want the program flow to be interupted. How can i do this? Something like the following: int[] manyInts = new int[4]; manyInts[0] = 1; manyInts[1] = 1; manyInts[2] = 1; manyInts[3] = 1; manyInts[4] = 1; manyInts[5] = 1; So basically it executes every statement whether it thows an exception or not. -- ABT

      J Offline
      J Offline
      Jim Stewart
      wrote on last edited by
      #2

      How about:

      try //Outside try block to handle initialization and leave the array visible
      {
      int[] manyInts = new int[4];

      try {manyInts\[0\] = 1;} 
      catch {/\*Empty catch block does nothing\*/}
      
      try {manyInts\[1\] = 1;} 
      catch {}
      
      try {manyInts\[2\] = 1;}
      catch {}
      
      try {manyInts\[3\] = 1;}
      catch {}
      
      try {manyInts\[4\] = 1;}
      catch {}
      
      try {manyInts\[5\] = 1;}
      catch {}
      

      }
      catch {}

      ...Powerful kludgy - but should work

      α.γεεκ

      Fortune passes everywhere.
      Duke Leto Atreides

      A 1 Reply Last reply
      0
      • J Jim Stewart

        How about:

        try //Outside try block to handle initialization and leave the array visible
        {
        int[] manyInts = new int[4];

        try {manyInts\[0\] = 1;} 
        catch {/\*Empty catch block does nothing\*/}
        
        try {manyInts\[1\] = 1;} 
        catch {}
        
        try {manyInts\[2\] = 1;}
        catch {}
        
        try {manyInts\[3\] = 1;}
        catch {}
        
        try {manyInts\[4\] = 1;}
        catch {}
        
        try {manyInts\[5\] = 1;}
        catch {}
        

        }
        catch {}

        ...Powerful kludgy - but should work

        α.γεεκ

        Fortune passes everywhere.
        Duke Leto Atreides

        A Offline
        A Offline
        Adam Turner
        wrote on last edited by
        #3

        HA. :-D That is extactly the work around that i am using.

        J 1 Reply Last reply
        0
        • A Adam Turner

          HA. :-D That is extactly the work around that i am using.

          J Offline
          J Offline
          Jim Stewart
          wrote on last edited by
          #4

          Sprinkle liberally with cheese and enjoy.

          α.γεεκ

          Fortune passes everywhere.
          Duke Leto Atreides

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups