Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
question 1) is the follwong code is correct because first time i'm learning try catch
C#
try
    {
    string x = (string)GetGlobalResourceObject(Resource1, value);

    Label1.Text = string.Format("{0}", x);
    }

catch (Exeption ex)
{
    Response.Write(ex.ToString());
}


question 2) when i run it i get the error like

Error	1	The type or namespace name 'Exeption' could not be found (are you missing a using directive or an assembly reference?)	C:\Documents and Settings\cmsdev3\My Documents\Visual Studio 2005\Projects\CreatingCheckBoxList\CreatingCheckBoxList\new.aspx.cs	44	28	CreatingCheckBoxList


and

Error	2	The name 'ex' does not exist in the current context	C:\Documents and Settings\cmsdev3\My Documents\Visual Studio 2005\Projects\CreatingCheckBoxList\CreatingCheckBoxList\new.aspx.cs	46	40	CreatingCheckBoxList


[edit]Code blocks tidied, and one added, "Treat my content as plain text..." option disabled, indentation - OriginalGriff[/edit]
Posted
Updated 13-Sep-11 8:24am
v2

That is because Exception is spelled with a 'c'...
 
Share this answer
 
Comments
rajh7 13-Sep-11 14:37pm    
thanks
#realJSOP 13-Sep-11 15:07pm    
5 - Proposed as answer (because it was submitted first)
First throw and then try to catch it! Just kidding :)
The syntax looks correct. However, you need to use
C#
catch(System.Exception ex)
or use
C#
using System;
in the beginning of your file. This hint can be seen in the error statement itself.
The type or namespace name 'Exeption' could not be found (are you missing a using directive or an assembly reference?)
Hope this helps.

Also noted that Exception is misspelled.
 
Share this answer
 
v2
Comments
rajh7 13-Sep-11 14:37pm    
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900