Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / October 2007

Tip: Looking for answers? Try searching our database.

What is type safty in dot net?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bhuwan Bhaskar - 20 Oct 2007 05:38 GMT
Hi,

What is type safety in Dot net?

Bhuwan
Jon Skeet [C# MVP] - 20 Oct 2007 08:05 GMT
> 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?

Signature

Jon Skeet - <skeet@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

Scott M. - 20 Oct 2007 14:39 GMT
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

> Hi,
>
> What is type safety in Dot net?
>
> Bhuwan
Göran Andersson - 21 Oct 2007 09:26 GMT
> Essentially, it means that the compiler won't let you treat an apple like a
> trampoline.
[quoted text clipped - 6 lines]
> 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
>
[quoted text clipped - 3 lines]
>>
>> Bhuwan

Signature

Göran Andersson
_____
http://www.guffa.com

Scott M. - 21 Oct 2007 21:38 GMT
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.

>> Essentially, it means that the compiler won't let you treat an apple like
>> a trampoline.
[quoted text clipped - 21 lines]
>>>
>>> Bhuwan
Göran Andersson - 21 Oct 2007 21:55 GMT
> 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.

Signature

Göran Andersson
_____
http://www.guffa.com

Bhuwan Bhaskar - 22 Oct 2007 05:32 GMT
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
>> Well, I think when most folk talk about type-safety, they are referring
>> to design-time, not run time.
[quoted text clipped - 11 lines]
> 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 - 22 Oct 2007 07:22 GMT
> 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.

A type safe language won't allow operations or conversions that can give
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

Signature

Göran Andersson
_____
http://www.guffa.com

Bhuwan Bhaskar - 20 Oct 2007 17:40 GMT
Thanks all !

Bhuwan
> Hi,
>
> What is type safety in Dot net?
>
> Bhuwan

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.