Difference between type cast and Convert.int32 ?

Can any one explain me the difference between the below 2 statements.

status = (int)InvoiceStatus.VALID;

status = Convert.ToInt32(InvoiceStatus.VALID);

Which is better and faster? And when should I use which?
GouthamAnandAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Leon TealePenetration TesterCommented:
They pretty much do the same thing.  If you're just changing data from one form to another for use, such as changing a "45" from a varchar to an int, use CAST; Convert offers more options than cast which may lead to more processing time.  And by this, I of course mean MINIMAL, not noticeable processing time.  Convert allows you to add a format style to your convertion, if you want it to.  For example, if you're changing a date to a string, you can say which part of the date to return instead of returning the whole thing and making .NET format it.
0
BinuthCommented:
Casting will throw an exception if it fails or the input is null. The Convert class will return 0 if the input is null.
0
ajollyCommented:
difference will depend on the type of variable2.

For instance, if InvoiceStatus.VALID has a value which is a string reference to
"23" then Convert.ToInt32 will parse the int. However, you can't *cast*
from a string to an int.
0
Anurag ThakurTechnical ManagerCommented:
go through the following link - good discussion for cast vs convert
http://bytes.com/forum/thread266654.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GouthamAnandAuthor Commented:
Thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.