.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> C# >> Post New Question Subscribe to Interview Questions

What is the difference between int.Parse and int.TryParse methods?

Posted By :SanthoshNathan     Posted Date :November 01, 2010    Points :10   Category :C# 
Parse method throws an exception if the string you are trying to parse is not a valid number where as TryParse returns false and does not throw an exception if parsing fails. Hence TryParse is more efficient than Parse

You can also find related Interview Question to What is the difference between int.Parse and int.TryParse methods?  below: 

Difference between int.Parse and int.TryParse

  
Parse method throws an exception, if the string you are trying to parse is not a valid number , whereas TryParse returns false and does not throw an exception if parsing fails. (More...)

Difference between Int.parse and int.TryParse?

  
Int.parse: Convert string to integer.it thrown exception when null or invalid input is provided with the Parse menthod
Int.TryParse: Does not thrown exception instead it returns boolean value.
(More...)

Difference between Double.Parse and Double.TryParse ?

  
Double.Parse will throw an exception on non-numbers or null
Double.TryParse will return false or 0 on any of the above without generating an exception. (More...)

Difference between Parse vs TryParse?

  
Parse method is used to parse any value to specified data type.
TryParse is a good method if the string you are converting to an integer is not always numeric. The TryParse method returns a boolean to denote whether the conversion has been successfull or not, and returns the converted value through an out parameter. (More...)

Difference Between GET and POST methods in HTML

  
Difference Between GET and POST methods

GET:
1) Data is appended to the URL.
2) Data is not secret.
3) It is a single call system
4) Maximum data that can be sent is 256.
5) Data transmission is faster
6) This is the default method for many browsers

POST:
1) Data is appended to the URL.
2) Data is Secret
3) It is a two call system.
4) There is no Limit on the amount of data.That is characters any amount of data can be sent.
5) Data transmission is comparatively slow.
6) No default and should be Explicitly specified. (More...)

Difference between Int32.Parse,Convert.Int32

  
Int32.Parse Method:
-------------------
Converts the string representation of a number to its 32-bit signed integer equivalent.
-When s is a null reference, it will throw ArgumentNullException.
-If s is other than integer value, it will throw FormatException.
-When s represents a number out of range, it will throw OverflowException.

Convert.ToInt32(string):
-------------------------
Converts the specified string representation of 32-bit signed integer equivalent. This calls in turn Int32.Parse () method.
-When s is a null reference, it will return 0 rather than throw ArgumentNullException.
-If s is other than integer value, it will throw FormatException.
-When s represents a number out of range, it will throw OverflowException.

Int32.TryParse Method:
----------------------
Converts the specified string representation of 32-bit signed integer equivalent to out variable, and returns true if it is parsed successfully, false otherwise.
-When s is a null reference, it will return 0.
-If s is other than an integer value, the out variable will have 0.
-When s represents a number out of range, the out variable will have 0. (More...)

Expalin one difference between Abstract and virtual methods?

  
Virtual method can be overriden in any of its derived class and abstract method must be overriden in any of the non abstract class. (More...)

What is the difference between Skip() and SkipWhile() extension methods?

  
Skip() will take an integer argument and skips the top n numbers from the given IEnumerable

SkipWhile() continues to skip the elements as long as the input condition is true. Once condition turns false it will return all remaining elements. (More...)

What is the difference between Execute Reader, Execute Scalar and Execute Non Query methods?

  
Execute Reader
Execute Reader will be used to return the set of rows, on execution of SQL Query or Stored procedure using command object.

Execute Scalar
Execute Scalar will be used to return the single value, on execution of SQL Query or Stored procedure using command object.

Execute Non Query
If the command or stored procedure performs INSERT, DELETE or UPDATE operations, then we use Execute Non Query method. Execute Non Query method returns an integer specifying the number of rows inserted, deleted or updated.

(More...)

Which one is faster?
int.Parse()
int.TryParse()
Convert.ToInt32()

  
int.TryParse() is relativly faster when compared to others (More...)

What is difference between Load() and LoadQuery() methods ?

  

Ans. Load method populates the client object directly with what it gets data from the server i.e. a collection object like ListItemCollection etc. but LoadQuery returns the data as a completely new collection in IEnumerable format. Other major difference is that the Collections that you load using the Load() method are eligible for garbage collection only when the client context variable itself goes out of scope where as, in these collections go out of scope at the end of IEnumerable list. (More...)


Q. What is difference between Load() and LoadQuery() methods ?

  
Ans. Load method populates the client object directly with what it gets data from the server i.e. a collection object like ListItemCollection etc. but LoadQuery returns the data as a completely new collection in IEnumerable format. Other major difference is that the Collections that you load using the Load() method are eligible for garbage collection only when the client context variable itself goes out of scope where as, in these collections go out of scope at the end of IEnumerable list.

(More...)

What is the difference between static and instance methods

  
A method declared with a static modifier is a static method. A static method does not operate on a specific instance and can only access static members.

A method declared without a static modifier is an instance method. An instance method operates on a specific instance and can access both static and instance members. The instance on which an instance method was invoked can be explicitly accessed as this. It is an error to refer to this in a static method.
(More...)

What is the difference between the Clone() and Copy() methods of the DataSet class?

  
The Clone() method copies only the structure of a DataSet. The copied structure includes all the relation, constraint, and DataTable schemas used by the DataSet. The Clone() method does not copy the data, which is stored in the DataSet.

The Copy() method copies the structure as well as the data stored in the DataSet. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend