473,396 Members | 1,918 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,396 software developers and data experts.

VB to C#how does DirectCast convert?

I have this line in VB and I need to convert it to C#:
Return DirectCast(HttpContext.Current.Session("LastExcept ion"), Exception)

I've been unable to find an equivelent to DirectCast and I can't seem to get
Convert.ChangeType to work for me either. This is what I have t the moment:

return Convert.ChangeType(HttpContext.Current.Session["LastException"],
Exception);

Any idea what I'm doing wrong? Am I using the wrong function, not loading
it correctly?

Any help would be appreciated!

Andrea
Nov 18 '05 #1
2 1611
return (Exception) HttpContext.Current.Session["LastException"];
"Andrea Williams" <an*******@hotmail.IHATESpam.com> wrote in message
news:ew**************@TK2MSFTNGP11.phx.gbl...
I have this line in VB and I need to convert it to C#:
Return DirectCast(HttpContext.Current.Session("LastExcept ion"), Exception)

I've been unable to find an equivelent to DirectCast and I can't seem to get Convert.ChangeType to work for me either. This is what I have t the moment:
return Convert.ChangeType(HttpContext.Current.Session["LastException"],
Exception);

Any idea what I'm doing wrong? Am I using the wrong function, not loading
it correctly?

Any help would be appreciated!

Andrea

Nov 18 '05 #2
That worked!!! thank you so much!
"bruce barker" <no***********@safeco.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
return (Exception) HttpContext.Current.Session["LastException"];
"Andrea Williams" <an*******@hotmail.IHATESpam.com> wrote in message
news:ew**************@TK2MSFTNGP11.phx.gbl...
I have this line in VB and I need to convert it to C#:
Return DirectCast(HttpContext.Current.Session("LastExcept ion"), Exception)
I've been unable to find an equivelent to DirectCast and I can't seem to

get
Convert.ChangeType to work for me either. This is what I have t the

moment:

return Convert.ChangeType(HttpContext.Current.Session["LastException"],
Exception);

Any idea what I'm doing wrong? Am I using the wrong function, not loading it correctly?

Any help would be appreciated!

Andrea


Nov 18 '05 #3

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

Similar topics

5
by: William Ryan | last post by:
In a nutshell, I need to get the name of the object that was just pressed (in this case, the object will be a radioButton). I want to write one handler for all four radio buttons and branch off...
4
by: Andreas Klemt | last post by:
Hello, what has the better performance and what are you using? Dim myObj As Object = 70 a) Dim myInt As Integer = DirectCast(myObj, Integer) b) Dim myInt As Integer = Convert.ToInt32(myObj) ...
6
by: Ot | last post by:
I apparently have a bit to learn about Casting and Conversion. I have been thinking of them as the same but a discussion in another thread leads me to believe that this is wrong thinking. I...
5
by: Michael Ramey | last post by:
Hello, There are quite a few ways to convert one object, say an integer to a string. Dim myStr as string dim myInt as integer = 123 myStr = cstr(myInt) myStr = myInt.toString()
6
by: Charles Law | last post by:
I want to do something like this: obj = CType(value, Value.Type) Well, not exactly, but I think that captures the essence. I realise it won't work as I have written it, and it looks a bit like...
5
by: Brian Henry | last post by:
Which is faster or considered the better way to do this. I have a object that holds a date... Convert.ToDate(object) or Directcast(object,DateTime) ? Thanks
5
by: Paul Timmerman | last post by:
Dim CurrentTabPage As Control CurrentTabPage = DirectCast("tcontrol.SelectedTab.Name", Control) MessageBox.Show(CurrentTabPage.Name) I get a SPECIFIED CAT IS NOT VALID Simply described:
1
by: Brett | last post by:
I'm having difficults getting at values of an object. Here is my code, which only gets a webpage. The two values I can't reach have comments next to them. I've also listed the watches tree and...
10
by: Dan | last post by:
Hi, I create 5 dropdownlist in code-behind. I want to insert their selectedvalues in a table by making a string separated with ":" I can get their selecedvalues but i'm stuck when i want to...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.