|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
What is type safty in dot net?Bhuwan Bhaskar <k***@gmail.com> wrote:
> What is type safety in Dot net? Well, that's a very broad question. What's the context? What exactly are you trying to find out? -- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too Essentially, it means that the compiler won't let you treat an apple like a
trampoline. In other words, the compiler looks at the "type" you are working with in your statements and makes sure that you only do things with or to that type that are allowed for that type. C# has this automatic type-safety built in by defalut. With VB .NET, you must change the Option Strict setting in Tools...Options to On (the default is off). -Scott Show quote "Bhuwan Bhaskar" <k***@gmail.com> wrote in message news:u9Xk2OtEIHA.5160@TK2MSFTNGP05.phx.gbl... > Hi, > > What is type safety in Dot net? > > Bhuwan > > > Scott M. wrote:
> Essentially, it means that the compiler won't let you treat an apple like a VB.NET is actually type safe regardless of the Option Strict setting.> trampoline. > > In other words, the compiler looks at the "type" you are working with in > your statements and makes sure that you only do things with or to that type > that are allowed for that type. > > C# has this automatic type-safety built in by defalut. With VB .NET, you > must change the Option Strict setting in Tools...Options to On (the default > is off). With the setting off it allows a lot of implicit conversions that is not allowed in strict mode, but the conversions are still type safe. If the conversion would produce an unusable result, you get a runtime error instead. > -Scott > > "Bhuwan Bhaskar" <k***@gmail.com> wrote in message > news:u9Xk2OtEIHA.5160@TK2MSFTNGP05.phx.gbl... >> Hi, >> >> What is type safety in Dot net? >> >> Bhuwan >> >> Well, I think when most folk talk about type-safety, they are referring to
design-time, not run time. After all, with your definition, you could make the argument that VB .NET is also bug-safe, since you'll get a runtime exception or runtime anomoly when the program encounters bugs. If there were such a thing as a bug-safe language, you'd expect it would indicate a bug as your were creating the bug. Show quote "Göran Andersson" <gu***@guffa.com> wrote in message news:%23QCcLw7EIHA.4308@TK2MSFTNGP06.phx.gbl... > Scott M. wrote: >> Essentially, it means that the compiler won't let you treat an apple like >> a trampoline. >> >> In other words, the compiler looks at the "type" you are working with in >> your statements and makes sure that you only do things with or to that >> type that are allowed for that type. >> >> C# has this automatic type-safety built in by defalut. With VB .NET, you >> must change the Option Strict setting in Tools...Options to On (the >> default is off). > > VB.NET is actually type safe regardless of the Option Strict setting. > > With the setting off it allows a lot of implicit conversions that is not > allowed in strict mode, but the conversions are still type safe. If the > conversion would produce an unusable result, you get a runtime error > instead. > >> -Scott >> >> "Bhuwan Bhaskar" <k***@gmail.com> wrote in message >> news:u9Xk2OtEIHA.5160@TK2MSFTNGP05.phx.gbl... >>> Hi, >>> >>> What is type safety in Dot net? >>> >>> Bhuwan >>> >>> > > > > -- > Göran Andersson > _____ > http://www.guffa.com Scott M. wrote:
> Well, I think when most folk talk about type-safety, they are referring to Then they are confused, as that is strong typing, not type safety.> design-time, not run time. > After all, with your definition, The definition is not mine.> you could make Not at all. A bug can very well result in a perfectly normal result, > the argument that VB .NET is also bug-safe, since you'll get a runtime > exception or runtime anomoly when the program encounters bugs. even if it isn't the correct result. Hi Göran,
what are your views for 'type safety' and 'strongly typed' in dot net. I will be obliged if you make my concept clear on these terms. Thanks, Bhuwan Show quote "Göran Andersson" <gu***@guffa.com> wrote in message news:%23aDdPTCFIHA.5328@TK2MSFTNGP05.phx.gbl... > Scott M. wrote: >> Well, I think when most folk talk about type-safety, they are referring >> to design-time, not run time. > > Then they are confused, as that is strong typing, not type safety. > >> After all, with your definition, > > The definition is not mine. > >> you could make the argument that VB .NET is also bug-safe, since you'll >> get a runtime exception or runtime anomoly when the program encounters >> bugs. > > Not at all. A bug can very well result in a perfectly normal result, even > if it isn't the correct result. > > -- > Göran Andersson > _____ > http://www.guffa.com Bhuwan Bhaskar wrote:
> what are your views for 'type safety' and 'strongly typed' in dot net. I A type safe language won't allow operations or conversions that can give > will be obliged if you make my concept clear on these terms. an illegal result. For example, converting a Long to an Integer i VB.NET will check that the value is actually possible to store in an Integer. A strongly typed language enforces type conversions to be explicit. For example, with Option Explicit On VB.NET will not implicitly convert a string to a number, but with Option Explicit Off, it will. Type safety: http://en.wikipedia.org/wiki/Type_system#Safely_and_unsafely_typed_systems Type strength: http://en.wikipedia.org/wiki/Type_system#Strong_and_weak_typing Thanks all !
Bhuwan Show quote "Bhuwan Bhaskar" <k***@gmail.com> wrote in message news:u9Xk2OtEIHA.5160@TK2MSFTNGP05.phx.gbl... > Hi, > > What is type safety in Dot net? > > Bhuwan > > > |
|||||||||||||||||||||||