473,566 Members | 2,763 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Option strict require more casting?

I find there is more casting required in C# than VB.NET. If Option
Strict/Explicit is turned on, will this basically create the same
environment as C# - uppercase, more casting required, must build event
handlers?

Thanks,
Brett
Nov 21 '05 #1
6 1567
Brett,

No Option Strict does not make from VBNet a kind of C#. To answer you direct
on your lower/uppercase question. The distinct between uppercase and
lowercase is not CLS compliant. However when used in private values in C
languages no problem.

With option strict on, the casting is exactly the same. However by instance
unsafe code is still not possible with VBNet, while in there stays
background compiling to help you direct with errors and auto complete what
is not in C#.

I hope this helps,

Cor
Nov 21 '05 #2
The only thing it will do is require you to declare your variables and
perform the casts. It does not affect the way event handlers are hooked up
for you (static or dynamic) and has no affect on case sensitivity. It is
highly recommended to Set Explicit ON and Set Option Strict ON for any new
VB.NET project. You may need to set them off when converting old VB6 code or
if you are doing late binding and you know what you are working with.

HTH,
-B

"Brett" <no@spam.com> wrote in message
news:uu******** ******@TK2MSFTN GP15.phx.gbl...
I find there is more casting required in C# than VB.NET. If Option
Strict/Explicit is turned on, will this basically create the same
environment as C# - uppercase, more casting required, must build event
handlers?

Thanks,
Brett

Nov 21 '05 #3
VB with Option Strict On is actually *more* strict than C#, believe it or
not. That is, C# will let you get away with a lot more implicit casting than
VB with option strict on.

David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter
and the Instant VB C# to VB.NET converter

"Brett" wrote:
I find there is more casting required in C# than VB.NET. If Option
Strict/Explicit is turned on, will this basically create the same
environment as C# - uppercase, more casting required, must build event
handlers?

Thanks,
Brett

Nov 21 '05 #4
Well i have some different thoughts about this
I set Option explicit and Option strict on by default above every code
block and not default in the project cause in some circumstances option
explicit is more a pain in the but and i want to have control over it where
to use it or not

when would i not use option strict ???
Well those of you ever involved in writing a remoting project or writing
there own proxy class for webservices will know why ,,,,, cause there are
situations where late binding is actually handy
and it sure is not bad to use it ... that is why remoting is so much
easier to acomplish in VB as in C#

happy coding

M. Posseth [MCP Developer]

"Beth Massi [Architect MVP]" <bm****@comcast .net> wrote in message
news:eo******** ******@TK2MSFTN GP10.phx.gbl...
The only thing it will do is require you to declare your variables and
perform the casts. It does not affect the way event handlers are hooked up
for you (static or dynamic) and has no affect on case sensitivity. It is
highly recommended to Set Explicit ON and Set Option Strict ON for any new
VB.NET project. You may need to set them off when converting old VB6 code or if you are doing late binding and you know what you are working with.

HTH,
-B

"Brett" <no@spam.com> wrote in message
news:uu******** ******@TK2MSFTN GP15.phx.gbl...
I find there is more casting required in C# than VB.NET. If Option
Strict/Explicit is turned on, will this basically create the same
environment as C# - uppercase, more casting required, must build event
handlers?

Thanks,
Brett


Nov 21 '05 #5
I agree. That's why I said you may want to set Option Strict Off if you are
doing late binding. Like it comes in handy when you have to write a lot of
Reflection code too. You just need to be really careful because potential
errors won't spring up until runtime.

"M. Posseth" <mi*****@nohaus ystems.nl> wrote in message
news:d5******** **@reader08.wxs .nl...
Well i have some different thoughts about this
I set Option explicit and Option strict on by default above every code
block and not default in the project cause in some circumstances option
explicit is more a pain in the but and i want to have control over it
where
to use it or not

when would i not use option strict ???
Well those of you ever involved in writing a remoting project or writing
there own proxy class for webservices will know why ,,,,, cause there are
situations where late binding is actually handy
and it sure is not bad to use it ... that is why remoting is so much
easier to acomplish in VB as in C#

happy coding

M. Posseth [MCP Developer]

"Beth Massi [Architect MVP]" <bm****@comcast .net> wrote in message
news:eo******** ******@TK2MSFTN GP10.phx.gbl...
The only thing it will do is require you to declare your variables and
perform the casts. It does not affect the way event handlers are hooked
up
for you (static or dynamic) and has no affect on case sensitivity. It is
highly recommended to Set Explicit ON and Set Option Strict ON for any
new
VB.NET project. You may need to set them off when converting old VB6 code

or
if you are doing late binding and you know what you are working with.

HTH,
-B

"Brett" <no@spam.com> wrote in message
news:uu******** ******@TK2MSFTN GP15.phx.gbl...
>I find there is more casting required in C# than VB.NET. If Option
>Strict/Explicit is turned on, will this basically create the same
>environment as C# - uppercase, more casting required, must build event
>handlers?
>
> Thanks,
> Brett
>



Nov 21 '05 #6

Then we speak the same Language :-)

"Beth Massi [Architect MVP]" <bm****@comcast .net> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I agree. That's why I said you may want to set Option Strict Off if you are doing late binding. Like it comes in handy when you have to write a lot of
Reflection code too. You just need to be really careful because potential
errors won't spring up until runtime.

"M. Posseth" <mi*****@nohaus ystems.nl> wrote in message
news:d5******** **@reader08.wxs .nl...
Well i have some different thoughts about this
I set Option explicit and Option strict on by default above every code
block and not default in the project cause in some circumstances option explicit is more a pain in the but and i want to have control over it
where
to use it or not

when would i not use option strict ???
Well those of you ever involved in writing a remoting project or writing
there own proxy class for webservices will know why ,,,,, cause there are situations where late binding is actually handy
and it sure is not bad to use it ... that is why remoting is so much
easier to acomplish in VB as in C#

happy coding

M. Posseth [MCP Developer]

"Beth Massi [Architect MVP]" <bm****@comcast .net> wrote in message
news:eo******** ******@TK2MSFTN GP10.phx.gbl...
The only thing it will do is require you to declare your variables and
perform the casts. It does not affect the way event handlers are hooked
up
for you (static or dynamic) and has no affect on case sensitivity. It is highly recommended to Set Explicit ON and Set Option Strict ON for any
new
VB.NET project. You may need to set them off when converting old VB6
code or
if you are doing late binding and you know what you are working with.

HTH,
-B

"Brett" <no@spam.com> wrote in message
news:uu******** ******@TK2MSFTN GP15.phx.gbl...
>I find there is more casting required in C# than VB.NET. If Option
>Strict/Explicit is turned on, will this basically create the same
>environment as C# - uppercase, more casting required, must build event
>handlers?
>
> Thanks,
> Brett
>



Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2129
by: Microsoft News | last post by:
I have a project that was created all with Option Strict OFF. Works great, not a problem with it. But if I turn Option Strict ON then I get a LOT of errors. My question, should I even care about Option Strict? What advantages do I get with Option Strict On? Does better type statement make my code run faster? If anyone knows THE...
1
1681
by: fabrice | last post by:
Hello I have a little problem with casting in a Datagrid Control. I'm using Option Strict in my web application. In a Template Column, I put in an ImageButton Control with a Command Argument using Container.DataItem. Différent expressions as System.Convert.ToString(Container.DataItem("Column"))) bring an Error :
8
3819
by: Nathan | last post by:
Hi, I have an operation in which I divide one integer by another and assign the result to a third integer. However, I get the error message: "Option Strict On disallows implicit conversions from 'Double' to 'Integer'." I know this can be avoided by using CInt; however, what would be the affect in how my code works if I turn Option Strict...
13
2499
by: Shannon Richards | last post by:
Hello: I have a problem using ByRef arguments with Option Strict ON. I have built a generic sub procedure "ChangeValue()" to change the value of an argument if the new value is not the same as the original value...To accommodate all variable types I made the arguments in ChangeValue() of type object...I then check the typecode and do the...
30
1833
by: Microsoft News | last post by:
I have a project that was created all with Option Strict OFF. Works great, not a problem with it. But if I turn Option Strict ON then I get a LOT of errors. My question, should I even care about Option Strict? What advantages do I get with Option Strict On? Does better type statement make my code run faster? If anyone knows THE...
1
3762
by: m830266 | last post by:
I'm trying to use the APAX serial I/O control (www.turbocontrol.com/AProZilla.htm) in a VB.NET project and I'm having trouble with its 'data received' events. The data is supplied by APAX as a variant which appears to VB.NET as a System.Object. I want to convert this to a System.Array so that I can iterate over its elements. The VB6 usage...
15
1536
by: guy | last post by:
when i first started using .net (beta 1) i came across option strict and thought hey this could be really good, and since then have always turned it on, most people here seem to agree that this is a good thing. i have now been asked to debug a vb2005 web app for 3 weeks and there is no mention of option strict in it, (there are also no...
8
2414
by: Rory Becker | last post by:
A wise man once said: "Never put off until runtime what you can fix at compile time." Actually I think he said it about 10 minutes before I started this post. I am a firm believer, like the man in question, in "Option Strict On" by default. Actually I don't believe I have code where this is not the case.
8
3879
by: =?Utf-8?B?R3JlZw==?= | last post by:
We have an application in our office that has the Option Strict option set to off right now. I do understand it should be set to ON, but right now, I'm just going to continue with it this way since I do not have the time to fix everything to set it to ON. Anyway, my question is if its set to OFF why is it it keeps getting set back to ON,...
0
7666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8108
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7644
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7951
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.