UrbanPro

Learn ASP.NET from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

What is difference between "throw" and "throw ex" in .Net?

Asked by Last Modified  

25 Answers

Learn ASP.NET

Follow 0
Answer

Please enter your answer

IT Course Training

Yes, there is a difference; 1) throw ex resets the stack trace (so your errors would appear to originate from HandleException) 2) throw doesn't - the original offender would be preserved.
Comments

Training Centre

1.In Throw, the original exception stack trace will be retained. To keep the original stack trace information, the correct syntax is 'throw' without specifying an exception. 2. In Throw ex, the original stack trace information will get override and you will lose the original exception stack trace....
read more
1.In Throw, the original exception stack trace will be retained. To keep the original stack trace information, the correct syntax is 'throw' without specifying an exception. 2. In Throw ex, the original stack trace information will get override and you will lose the original exception stack trace. I.e. 'throw ex' resets the stack trace read less
Comments

IT Professional Trainer with above 10 years of experience into software IT training

Using Throw statement you can either throw a system exception or your own custom exception
Comments

Expert Microsoft Technology Trainer (SharePoint, Dot Net, MSBI, SQL Server)

In Throw, the original exception stack trace will be retained. To keep the original stack trace information, the correct syntax is 'throw' without specifying an exception. In Throw ex, the original stack trace information will get override and you will lose the original exception stack trace. I.e....
read more
In Throw, the original exception stack trace will be retained. To keep the original stack trace information, the correct syntax is 'throw' without specifying an exception. In Throw ex, the original stack trace information will get override and you will lose the original exception stack trace. I.e. 'throw ex' resets the stack trace read less
Comments

Tutor

throw= rethrow, you are returning/throwing original exception throw ex= throwing customized exception. i will change stack trace information as origin of exception ertc
Comments

.Net Trainer with 10 Years

Throw: the original exception stack trace will be retained. To keep the original stack trace information, the correct syntax is 'throw' without specifying an exception. in case of Throw ex. the original stack trace information will get override and you will lose the original exception stack tr...
Comments

Trainer

Throw: In Throw, the original exception stack trace will be retained. To keep the original stack trace information, the correct syntax is 'throw' without specifying an exception. Eg: try { // do some operation that can fail } catch (Exception ex) { // do some local cleanup throw; } Throw...
read more
Throw: In Throw, the original exception stack trace will be retained. To keep the original stack trace information, the correct syntax is 'throw' without specifying an exception. Eg: try { // do some operation that can fail } catch (Exception ex) { // do some local cleanup throw; } Throw ex: In Throw ex, the original stack trace information will get override and you will lose the original exception stack trace. I.e. 'throw ex' resets the stack trace. Eg: try { // do some operation that can fail } catch (Exception ex) { // do some local cleanup throw ex; } } read less
Comments

Training Redefined

Thow menas " Capturing and showing the history or trail of the error that means the point from where the error is raised so that you can go to the actual source of the error , its like contacting golden source so that you can correct it and it is the one of the best practices in .net also if you are...
read more
Thow menas " Capturing and showing the history or trail of the error that means the point from where the error is raised so that you can go to the actual source of the error , its like contacting golden source so that you can correct it and it is the one of the best practices in .net also if you are using any static code analysis tools like Gendarme / FxCop than it will show as an technical debt." Now Throw ex , it simply means that you are not concern about the source of the error but provide customize exception after handling it" If you want to learn more about the Technical Debt or TDD or code quality , please contact us. read less
Comments

In Throw, the original exception stack trace will be retained. To keep the original stack trace information, the correct syntax is 'throw' without specifying an exception. In Throw ex, the original stack trace information will get override and you will lose the original exception stack trace. I.e....
read more
In Throw, the original exception stack trace will be retained. To keep the original stack trace information, the correct syntax is 'throw' without specifying an exception. In Throw ex, the original stack trace information will get override and you will lose the original exception stack trace. I.e. 'throw ex' resets the stack trace. read less
Comments

throw re-throws the exception that was caught, and preserves the stack trace. throw ex throws the same exception, but resets the stack trace to that method. Unless you want to reset the stack trace (i.e. to shield public callers from the internal workings of your library), throw is generally the...
read more
throw re-throws the exception that was caught, and preserves the stack trace. throw ex throws the same exception, but resets the stack trace to that method. Unless you want to reset the stack trace (i.e. to shield public callers from the internal workings of your library), throw is generally the better choice, since you can see where the exception originated. read less
Comments

View 23 more Answers

Related Questions

What Is Asp ?
ASP.Net is a platform that is used to develope, Web, Desktop, Mobile and other kinds of applications. It supports many languages like C, C++, C#, F#, VB.Net etc. It all runs on a Integrated Development...
Sunita
What is the difference between asp.net and vb.net?
asp.net is web technology that is used in building web applications and websites. Vb.net is language that is used in writing programs that are utilizing the asp.net framework Asp.net contains...
Aadarsh
What is the difference between asp.net and c#.net?
1.Csharp is best known as C#. 2.C# is a programming language used when developing Asp.net. 3.The C# programming language is specially designed for easy use in practically any purpose. 4.Asp.net...
Aadarsh

Hi,

I have asp.net project with sql connection.I want connect database with asp.net and run the project and web config file there

In web.config: <connectionStrings> <add name="ConnectionString" connectionString="Data Source=192.168.1.25;Initial Catalog=Login;Persist Security Info=True;User ID=sa;Password=example.com" providerName="System.Data.SqlClient"...
Fathima
What is the difference between asp.net and vb.net?
ASP.Net is known as a development platform for the web, which in turn is known to help create robust web applications. It is known to contain innumerous libraries which have a wide range of functionality....
Manshi

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Export To Excel using StringBuilder in ASP.net MVC C#
public ActionResult Export() { StringBuilder sb = new StringBuilder(); //static file name, can be changes as per requirement string sFileName = "filename.xls"; //Bind...
M

Mohammad Shafi

1 0
1

Read CSV data using ODBC Connection
Codes to read the CSV data using ODBC Connection- Input File: File's Encoding format should be ANSI as below class Student{ public string CollegeId { get; set; } public string AdmissionDate...

ASP.NET - Introduction
ASP.NET is a web development platform, which provides a programming model, a comprehensive software infrastructure and various services required to build up robust web applications for PC, as well as mobile...

why need for Angular js for higher versions of Asp.net framework.
1. Optimization of performance in receiving messages between client and server. 2. Optimised display features. Explanation 1. Earlier versions of Asp.net had lack of performance of message transfer...

Format Date to “MM/dd/yyyy” in Webgrid ASP.Net MVC Razor View
Replace above line with below to apply ("DD/mm/yyyy") formatting to date field in WebGrid AllTicket.Column(columnName: "DueDate", header: "Due Date") grid.Column("Date",format:@<text> @item.Date.ToString("MM/dd/yyyy")</text>)
M

Mohammad Shafi

0 0
0

Looking for ASP.NET ?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for ASP.NET Classes?

The best tutors for ASP.NET Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn ASP.NET with the Best Tutors

The best Tutors for ASP.NET Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more