<p>In .Net you can read a string value into another data type using either <code>&lt;datatype&gt;.parse</code> or <code>Convert.To&lt;DataType&gt;</code>. </p>

<p>I'm not familiar with the fundamentals of parse versus convert so I am always at a loss when asked which one is better/faster/more appropriate. </p>

<p>So - which way is best in what type of circumstances?</p>

[{'answer_id': 18474, 'author': 'TheSmurf', 'author_id': 1975282, 'author_profile': 'https://Stackoverflow.com/users/1975282', 'pm_score': 3, 'selected': False, 'text': '<p>Here\'s an answer for you:</p>\n\n<p><a href="http://www.dotnetspider.com/forum/ViewForum.aspx?ForumId=77428" rel="nofollow noreferrer">http://www.dotnetspider.com/forum/ViewForum.aspx?ForumId=77428</a></p>\n\n<p>Though I think in modern versions of .NET, the best thing to do is use TryParse in any case, if there\'s any doubt that the conversion will work.</p>\n'}, {'answer_id': 18476, 'author': 'Dillie-O', 'author_id': 71, 'author_profile': 'https://Stackoverflow.com/users/71', 'pm_score': 1, 'selected': False, 'text': "<p>There is also the DirectCast method which you should use only if you are sure what the type of the object is. It is faster, but doesn't do any proper checks. I use DirectCast when I'm extracting values from a loosely typed DataTable when I know the type for each column.</p>\n"}, {'answer_id': 18477, 'author': 'AlexCuse', 'author_id': 794, 'author_profile': 'https://Stackoverflow.com/users/794', 'pm_score': 1, 'selected': False, 'text': "<p>If you need speed, I'm pretty sure a direct cast is the fastest way.  That being said, I normally use .Parse or .TryParse because is seems to make things easier to read, and behave in a more predictable manner.  </p>\n\n<p>Convert actually calls Parse under the hood, I believe.  So there is little difference there, and its really just seems to be a matter of personal taste.</p>\n"}, {'answer_id': 18523, 'author': 'Keith', 'author_id': 905, 'author_profile': 'https://Stackoverflow.com/users/905', 'pm_score': 5, 'selected': True, 'text': '<p>The <code>Convert.ToXXX()</code> methods are for objects that might be of the correct or similar type, while <code>.Parse()</code> and <code>.TryParse()</code> are specifically for strings:</p>\n\n<pre><code>//o is actually a boxed int\nobject o = 12345;\n\n//unboxes it\nint castVal = (int) 12345;\n\n//o is a boxed enum\nobject o = MyEnum.ValueA;\n\n//this will get the underlying int of ValueA\nint convVal = Convert.ToInt32( o );\n\n//now we have a string\nstring s = "12345";\n\n//this will throw an exception if s can\'t be parsed\nint parseVal = int.Parse( s );\n\n//alternatively:\nint tryVal;\nif( int.TryParse( s, out tryVal ) ) {\n    //do something with tryVal \n}\n</code></pre>\n\n<p>If you compile with optimisation flags TryParse is very quick - it\'s the best way to get a number from a string. However if you have an object that might be an int or might be a string Convert.ToInt32 is quicker.</p>\n'}, {'answer_id': 18525, 'author': 'saalon', 'author_id': 111, 'author_profile': 'https://Stackoverflow.com/users/111', 'pm_score': 2, 'selected': False, 'text': '<p>I\'m a big fan of <a href="http://msdn.microsoft.com/en-us/library/f02979c7.aspx" rel="nofollow noreferrer">TryParse</a>, since it saves you a lot of headache of error catching when there\'s a chance the value you\'re going to parse is not of the appropriate type.  </p>\n\n<p>My order is usually:</p>\n\n<ul>\n<li>Parse (if I can be sure the value will be the right type, and I do try to ensure this)</li>\n<li>TryParse (if I can\'t be sure, which happens whenever user input is involved, or input from a system you cannot control)</li>\n<li>Convert (which I think I have not used since I started using Parse and TryParse, but I could be wrong)</li>\n</ul>\n'}]
['https://Stackoverflow.com/questions/18465', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/149/']