Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Can anyone provide an example which explains the difference between a compile time error and a runtime error?
Posted 14-Nov-11 20:33pm
Edited 14-Nov-11 20:41pm
v2
Comments
André Kraak at 15-Nov-11 2:41am
   
DO NOT SHOUT when asking a question. When you use all capital letters it is seen as shouting on the Internet and considered rude. Next time when posting a question please use proper capitalization.
syedkhaleel at 15-Nov-11 2:54am
   
thanq for suggestins
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

A compile time error is one which is detected before teh program starts running:
int i = 17;
if (i - 5)
   {
   }
will cause a compilation error, because "i - 5" is not a boolean vlaue - it is integer - and if conditions must be bool in C#
 
A run time error is one that is only detected when the program runs:
int i = 17;
int[] ar = new int[3];
ar[i] = 42;
will cause a run time error, because the value of i being used as an array index is outside the bounds of the array.
 
Run time errors can be trapped with a try...catch block, compile time errors cannot.
  Permalink  
Comments
SChristmas at 1-May-12 2:22am
   
Good answer
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Yes, sure, someone can; most of the members would be able to do that, I'm sure.
Is that what you wanted to know?
 
—SA
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

On the first impression, I thought your are very beginner to Programming, but looking at your profile it does not seems to be true.
 
I think you should go back to basics.
 
http://en.wikipedia.org/wiki/Compiler
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 353
1 OriginalGriff 304
2 George Jonsson 258
3 Shemeemsha RA 138
4 Animesh Datta 130
0 OriginalGriff 5,985
1 Sergey Alexandrovich Kryukov 5,341
2 CPallini 4,760
3 George Jonsson 3,400
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 15 Nov 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100