473,398 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

is this redundant...

hey all,

Private Property mEmployeeDataset() As DsHRLIBR24
Get
Return DirectCast(Session("oDs"), DsHRLIBR24)
End Get
Set(ByVal Value As DsHRLIBR24)
Session("oDs") = Value
End Set
End Property

Is my DirectCast needed in this case?

thanks,
rodchar
Nov 19 '05 #1
3 1016
If you will be able to compile without it then no.

I do not know much about VB.NET in C# you must you cast in cases like that.

George.

"rodchar" <ro*****@discussions.microsoft.com> wrote in message news:53**********************************@microsof t.com...
hey all,

Private Property mEmployeeDataset() As DsHRLIBR24
Get
Return DirectCast(Session("oDs"), DsHRLIBR24)
End Get
Set(ByVal Value As DsHRLIBR24)
Session("oDs") = Value
End Set
End Property

Is my DirectCast needed in this case?

thanks,
rodchar
Nov 19 '05 #2
> Is my DirectCast needed in this case?

Not needed, but certainly acceptable. And not redundant.

The difference between CType and DirectCast is that CType will work as long
as there is a valid conversion defined for the expression and the object
type specified, whereas DirectCast will only work if the run-time types are
the same. For example:

Dim i As Integer = CType("23", Integer) 'Fine
Dim i As Integer = DirectCast("23", Integer) ' Exception

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:53**********************************@microsof t.com...
hey all,

Private Property mEmployeeDataset() As DsHRLIBR24
Get
Return DirectCast(Session("oDs"), DsHRLIBR24)
End Get
Set(ByVal Value As DsHRLIBR24)
Session("oDs") = Value
End Set
End Property

Is my DirectCast needed in this case?

thanks,
rodchar

Nov 19 '05 #3
thanks everyone for the help.

"Kevin Spencer" wrote:
Is my DirectCast needed in this case?


Not needed, but certainly acceptable. And not redundant.

The difference between CType and DirectCast is that CType will work as long
as there is a valid conversion defined for the expression and the object
type specified, whereas DirectCast will only work if the run-time types are
the same. For example:

Dim i As Integer = CType("23", Integer) 'Fine
Dim i As Integer = DirectCast("23", Integer) ' Exception

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:53**********************************@microsof t.com...
hey all,

Private Property mEmployeeDataset() As DsHRLIBR24
Get
Return DirectCast(Session("oDs"), DsHRLIBR24)
End Get
Set(ByVal Value As DsHRLIBR24)
Session("oDs") = Value
End Set
End Property

Is my DirectCast needed in this case?

thanks,
rodchar


Nov 19 '05 #4

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

Similar topics

5
by: dmcconkey | last post by:
Hi folks, I've been searching for a while and haven't found my specific question anywhere else. If this has already been asked, please accept my appologies and point me to the appropriate...
4
by: zzapper | last post by:
Hi, I've inherited a mysql database with many apparently redundant tables (probably abandoned projects). Without analysing the webpages many of which are also redundant; is there any MYSQL query...
5
by: gordy | last post by:
edit: this came out longer than I thought, any comments about anything here is greatly appreciated. thank you for reading My system stores millions of records, each with fields like firstname,...
4
by: GlobalBruce | last post by:
The global assembly cache on my development computer has duplicate native images of several System assemblies. For instance, the System assembly itself is present as two different native images, as...
14
by: Ian Pilcher | last post by:
It's pretty common to see declarations such as: static volatile sig_atomic_t caught_signal = 0; C99 defines sig_atomic_t as a "... (possibly volatile-qualified) integer type of an object that...
40
by: Neo The One | last post by:
I think C# is forcing us to write more code by enforcing a rule that can be summarized as 'A local variable must be assgined *explicitly* before reading its value.' If you are interested in what...
9
by: User1014 | last post by:
I'm a javascript noob and have a question concerning some code I've come across that I'm trying to understand. Here is a snippet of the relevant section: (snip) var closure = this; var xhr =...
3
by: =?Utf-8?B?R3JlZw==?= | last post by:
If I have an XmlDocument with a deep hierarchy of nodes, with a documentElement having an attribute xmlns="http://someurl.com" and all children inheriting that namespace (but not having the xmlns...
0
by: alan4cast | last post by:
I'm not a really new programmer, but I'm still working on learning all of the .net things that I should know. So when I came across this one, I started to dig into it so see if I could figure it...
0
bilibytes
by: bilibytes | last post by:
hi, I was wondering how to determine whether an information is redundant or not. if you have in a table "Main", the basic information for a thing: thing_id | name | image_id | city_id ok if...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
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,...

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.