Grazie in anticipo del suggerimento !<div><br></div><div>in questa linea di codice provoco un oveflow volutamente</div><div>tuttavia il generico try &amp; catch non lo cattura</div><div>come posso ovviare a questo ?</div><div>
<br></div><div>dopo l&#39;incremento posso ottenere artificialmente una eccezione</div><div>ma mi serviva in automatico , senza controllo con la if ?</div><div><br></div><div>grazie</div><div>claudio</div><div><br></div><div>
<br></div><div><div>using System;</div><div><br></div><div>    class<span class="Apple-tab-span" style="white-space:pre">        </span>uno</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> static int Main ( )</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>     sbyte bit8 = 127 ;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span> Int32 i = 10 ;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>    string s = i.ToString() ;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>Console.WriteLine ( i ) ;</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>Console.WriteLine ( s ) ;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>try </div><div><span class="Apple-tab-span" style="white-space:pre">                </span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                </span>if (++bit8&lt;0) throw new Exception(&quot;oh god it&#39;s broken&quot;);  </div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>Console.WriteLine( ++bit8) ;</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span> catch (Exception ex)</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>Console.WriteLine( &quot;Overflow&quot; );</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">                                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>return 0 ;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> }</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div></div><div><br></div>