Raj,
As the error message states, you need to put a constant value on the case
statement.
"io_exExcep tion is ApplicationHand ledException" is not a constant
expression.
You may want to consider using a series of if statements instead:
if (io_exException is ApplicationHand ledException)
| {
| if (i_blnPropagate Exception)
| {
| throw io_exException;
| }
| }
else if (io_exException is ApplicationBusi nessException)
| {
| if (i_blnPropagate Exception)
| {
| throw io_exException;
| }
| }
I would consider checking blnPropagateExc eption first, something like:
if (!i_blnPropagat eException)
return;
if (io_exException is ApplicationHand ledException)
throw io_exException;
else if (io_exException is ApplicationBusi nessException)
throw io_exException;
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
"Raj" <ra*******@logi cacmg.com> wrote in message
news:66******** *************** ***********@mic rosoft.com...
| public static void HandleException (ref Exception io_exException,
| bool
| i_blnPropagateE xception)
| {
| switch (true)
| {
| case io_exException is ApplicationHand ledException:
| {
| if (i_blnPropagate Exception)
| {
| throw io_exException;
| }
| break;
| }
| case io_exException is ApplicationBusi nessException:
| {
| if (i_blnPropagate Exception)
| {
| throw io_exException;
| }
| break;
| }
| }
| }
|
| This function is not compiling coming with error "A constant value is
| required". In the function 'ApplicationHan dledException' and
| 'ApplicationBus inessException' are classes inherited from
| System.Applicat ionException.
|
| Can someone please help me what is the reason and what is the way around?
If
| this is not possible what can be the alternative way?
|