|
-
Nov 29th, 2007, 01:28 AM
#1
Thread Starter
Addicted Member
What is this?
Hi:
I'm new to this, I read thru some example from MSDN:
I'm wondering what does this (int) meant?
Initialized e.Argument as Integer?
"int arg = (int)e.Argument;"
Thanks
-
Nov 29th, 2007, 03:12 AM
#2
Re: What is this?
I assume that that is in the DoWork event handler of a BackgroundWorker. The e.Argument property is type Object because you can pass any type of object as the argument. If you want to use it as its actual type then you have to cast it. If you passed an int and you want to use it as an int, e.g. assing it to an int variable, then you have to cast it as type int. That's what that's doing. It's saying that the object referred to by e.Argument is type int and the compiler should treat it as such.
-
Nov 29th, 2007, 03:28 AM
#3
Thread Starter
Addicted Member
Re: What is this?
(int)e.Argument
That Meant the (int) in front of e.Argument is actually a cast?
Like the CType in VB.net?
Thanks
-
Nov 29th, 2007, 03:32 AM
#4
Re: What is this?
 Originally Posted by simon ong
That Meant the (int) in front of e.Argument is actually a cast?
Yes, an explicit cast.
 Originally Posted by simon ong
Like the CType in VB.net?
Not quite. It's actually equivalent to DirectCast because CType will perform conversions that an explicit cast will not.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|