Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Wanna-Be C# Superstar
  • Leaders
Posted

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.

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...