Hack Forums
[.NET] Why Option Strict On? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Why Option Strict On? (/showthread.php?tid=1414882)



Why Option Strict On? - soft2050 - Jun 25, 2011

Hello

Does "Option Strict On" has any type of advantage while debugging? Less memory usage? Why should it be turned on?

Or it is just a good coding practise 🤦‍♂

There was one of my project which was ok with option strict off but there were around 62 errors when i turned on option strict on.

But they were solved by just Cstr and other problems .... 🤗


* - felicixus - Jun 25, 2011

It is very usefull while coding. If it is explicit, you will need to do all cast manually.
Do you know what does it mean!? xD


* - 6e756c6c - Jun 25, 2011

Yes it is better for the performance of your application.


* - Fake. - Jun 25, 2011

There are several reasons why you should have Option Strict On.

From MSDN
http://msdn.microsoft.com/en-us/library/zcd4xwzs%28v=vs.80%29.aspx Wrote:Data loss can occur when the value of one data type is converted to a data type with less precision or smaller capacity. A run-time error occurs if such a narrowing conversion fails. Option Strict ensures compile-time notification of these narrowing conversions so they can be avoided.

Because Option Strict On provides strong typing, prevents unintended type conversions with data loss, disallows late binding, and improves performance, its use is strongly recommended.



* - soft2050 - Jun 25, 2011

Thanks felicinox, Aeonhack , Fake™ for the info