TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dilshad Ashraf
1.5k
245
6k
What is difference between "throw" and "throw e"
Aug 18 2020 10:01 AM
Hi All,
I hope you all are doing well.
I have a question regarding throw and throw e,
I want to more clear on this exception topic.
I have written a simple program for the exception, program is below:
using
System;
public
class
Program
{
public
static
void
Main()
{
try
{
Int64 a = Convert.ToInt64(
"abc"
);
Console.WriteLine(a);
}
catch
(Exception e){
throw
;
}
}
}
Exception:
Run-time exception (line 12): Input string was not in a correct format.
Stack Trace:
[System.FormatException: Input string was not in a correct format.]
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt)
at System.Convert.ToInt64(String value)
at Program.Main() :line 12
try
{
Int64 a = Convert.ToInt64(
"abc"
);
Console.WriteLine(a);
}
catch
(Exception e){
throw
;
}
Exception:
Run-time exception (line 11): Input string was not in a correct format.
Stack Trace:
[System.FormatException: Input string was not in a correct format.]
at Program.Main() :line 11
I have seen only one difference when I am throwing with "e" getting full trace details, when not using only getting single line error details.
Is there any more difference or any other points, and what to use, "throw e" or "throw".
Thanks in advance.
Reply
Answers (
2
)
Generic SCV handler
Get Subcategory in List.