Lost Password?

Go Back   CodeCall Programming Forum > Software Development > C# Programming

Unregistered, Check out the Coder Battles in the Announcement and Game forums.

C# Programming C# (pronounced C-sharp) is a new object oriented language from Microsoft and is derived from C and C++. It also borrows a lot of concepts from Java too including garbage collection.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-06-2006, 08:17 PM
NeedHelp NeedHelp is offline
Programming God
 
Join Date: May 2006
Posts: 527
Credits: 0
Rep Power: 12
NeedHelp is on a distinguished road
Default Return in Finally

Is there a way to return a value in the finally section of a Try/Catch? I need a value populated if that occurs but can't seem to find a way to do it.
__________________
I Need Help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 08-07-2006, 07:42 AM
hoser2001's Avatar   
hoser2001 hoser2001 is offline
Programmer
 
Join Date: Jul 2006
Posts: 175
Credits: 0
Rep Power: 10
hoser2001 is on a distinguished road
Default

I don't see why you would have any more difficult of a time doing that in the finally section of the try/catch than in any other function. Could you give an example of what you're trying to do?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-09-2006, 09:32 PM
brackett brackett is offline
Programmer
 
Join Date: May 2006
Posts: 193
Credits: 0
Rep Power: 10
brackett is on a distinguished road
Default

You can't return out of a finally statement because of the way the stack is being unwound. The Finally block will run regardless of an exception or not, and isn't really practical to return out of anyway...

If you give an example of what you're trying to do, perhaps I could give you more info?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-10-2006, 07:16 AM
hoser2001's Avatar   
hoser2001 hoser2001 is offline
Programmer
 
Join Date: Jul 2006
Posts: 175
Credits: 0
Rep Power: 10
hoser2001 is on a distinguished road
Default

I never really thought about that before, it is known to me that the finally block would fire no matter what, however I didnt' know that you couldn't return from there.... Thanks for the explanation brackett. Do you have any good resources wehre I could read up on how 'stacks' work?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 08-16-2006, 09:31 PM
brackett brackett is offline
Programmer
 
Join Date: May 2006
Posts: 193
Credits: 0
Rep Power: 10
brackett is on a distinguished road
Default

The concept of a Stack is fairly simple. Push adds to the top, Pop takes off the top. It's basically a LIFO (Last In, First Out) queue (an actual Queue would be FIFO - First In, First Out; Push adds to the bottom, Pop takes off the top.).

For the stack concept applied to executing a program, typically termed a call stack, Wikipedia has a decent article. For specifics of the CLR execution stack, and the way a finally block is attached to it (as well as a lot more), Joe Duffy's Professional .NET Framework 2.0 is a pretty good, easy reading intro.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Return random numbers without duplicates Paradine PHP Tutorials 0 08-26-2007 02:07 PM
A simple TicTacToe game Zunone C and C++ 1 08-16-2007 11:01 AM
Dictonary Program programmer 101 Java Help 9 07-01-2007 01:39 PM
null exception problem connor7777 C# Programming 2 03-28-2007 11:37 AM
Two return methods NeedHelp C# Programming 3 07-18-2006 05:59 AM


All times are GMT -5. The time now is 07:35 PM.

Contest Stats

Xav ........ 1322.18
MeTh0Dz|Reb0rn ........ 1053.7
morefood2001 ........ 879.43
John ........ 877.37
marwex89 ........ 869.98
WingedPanther ........ 830.24
Brandon W ........ 733.07
chili5 ........ 309.39
Steve.L ........ 236.23
dcs ........ 212.02

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 82%

Ads