Click here to Skip to main content
13,046,087 members (49,796 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Can anyone provide an example which explains the difference between a compile time error and a runtime error?
Posted 14-Nov-11 20:33pm
Updated 14-Nov-11 20:41pm
André Kraak 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 15-Nov-11 2:54am
thanq for suggestins
Rate this: bad
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.
SChristmas 1-May-12 2:22am
Good answer
Rate this: bad
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?

Rate this: bad
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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 15 Nov 2011
Copyright © CodeProject, 1999-2017
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