Page 56 - E-Modul Pemrograman Dasar
P. 56

Contoh syntax exception handling adalah sebagai berikut.


                               Try
                               {
                                       … perintah …
                               }


                               catch (Exception ex)
                               {
                                       … perintah …
                               }


                               catch (Exception e)
                               {
                                       … perintah …
                               }


                               finally
                               {
                                       … perintah …
                               }

                       d.  Exception Class di C#

                              Ada beberapa exception class yang digunakan untuk menangani suatu exception.
                       Semua exception class diturunkan dari dua kelas utama.

                       1)  System.SystemException, yaitu suatu Predefined System Exception
                       2)  System.ApplicationException, yaitu suatu Application Program Exception
                              Ada  dua  kelas  yang  digunakan  dalam  exception  handling  di  C#,  beberapa  di
                       antaranya diturunkan dari exception clan, yaitu sebagai berikut.

                            Format Exception
                            Divide By Zero Exception
                            Null Reference Exception
                            Argument Null Exception
                            Not Finite Number Exception
                            Array Type Mismatch Exception
                            Argument Out Of Range Exception
                            Context Marshal Exception



                                                             47
   51   52   53   54   55   56   57   58   59   60   61