lothos12345 Posted May 27, 2005 Posted May 27, 2005 What are the benefits on having option strict on as opposed to turning it off? God knows its easier to develop an application with it off. Quote
VBAHole22 Posted May 27, 2005 Posted May 27, 2005 Leave it on. It's for your good health. It will trap errors during compile before they creep into your runtime and it will make your code stronger as you move forward. I think the type casting is probably the part most folks ***** about. If you leave it on for a month then you will know when you are casting something as you write the code. That way you have control over the cast and you know when it is happening. I have had instances when working with COM objects and third party dlls where I had to turn it off because I need late binding. That's where you don't know the type of somthing until runtime, I believe. Quote Wanna-Be C# Superstar
Leaders snarfblam Posted May 27, 2005 Leaders Posted May 27, 2005 It keeps your code tighter. It mostly helps me keep more aware of what is going on in my code. With option strict on, you can't make a narrowing conversion or cast without knowing it. With option strict off, people sometimes find themselves doing things like adding the numeric values of strings instead of concatenating them, or treating one type of object like another. Sometimes it is a little extra typing because you have to explicitly code all narrowing conversions (Integer to byte, String to integer, Object to Control, etc.) but it also helps because you can't perform a cast or conversion that could potentially cause errors without knowing it. Quote [sIGPIC]e[/sIGPIC]
Administrators PlausiblyDamp Posted May 28, 2005 Administrators Posted May 28, 2005 It's also a lot easier to introduce subtle errors with it turned off. Turning it on requires you to be more explicit about your intentions. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.