Click here to Skip to main content
15,899,634 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# Dll Debugging Pin
Christian Graus17-Feb-07 19:23
protectorChristian Graus17-Feb-07 19:23 
GeneralRe: C# Dll Debugging Pin
usermans17-Feb-07 19:36
usermans17-Feb-07 19:36 
GeneralRe: C# Dll Debugging Pin
Christian Graus17-Feb-07 20:00
protectorChristian Graus17-Feb-07 20:00 
Questiontry-catch question ... Pin
Hussam Fattahi17-Feb-07 18:56
Hussam Fattahi17-Feb-07 18:56 
AnswerRe: try-catch question ... Pin
Christian Graus17-Feb-07 19:22
protectorChristian Graus17-Feb-07 19:22 
GeneralRe: try-catch question ... Pin
Hussam Fattahi17-Feb-07 19:48
Hussam Fattahi17-Feb-07 19:48 
GeneralRe: try-catch question ... Pin
Christian Graus17-Feb-07 20:09
protectorChristian Graus17-Feb-07 20:09 
GeneralRe: try-catch question ... Pin
Scott Dorman18-Feb-07 4:21
professionalScott Dorman18-Feb-07 4:21 
Hussam Fattahi wrote:
i need to assign a value to 'remote' in try block, and then use that value within catch block.


Usually the only things you would need to do in the catch block are cleanup type activities. If you are trying to show the error message to the user you should be doing something like this:

int i =0;
Socket remote = null;
try
{
   remote = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
   i = 5;
}
catch(Exception ee)
{
   MessageBox.Show(i.ToString());
   MessageBox.Show(ee.Message);
}
The Socket remote = null; will remove the compiler issue about using an unassigned variable. Any variable that is used inside of a catch block must be explicitly assigned prior to it being used.

If the call to remote = new Socket(...) fails for any reason, remote will be null (in all cases), you will take an exception that puts you in your catch handler. At that point, remote is still null, so you are trying to run ToString() on a null reference, which you can't do.


-----------------------------
In just two days, tomorrow will be yesterday.

Questiontransparent floating window Pin
sushantkaura17-Feb-07 18:38
sushantkaura17-Feb-07 18:38 
AnswerRe: transparent floating window Pin
Ed.Poore17-Feb-07 20:00
Ed.Poore17-Feb-07 20:00 
GeneralRe: transparent floating window Pin
sushantkaura17-Feb-07 20:48
sushantkaura17-Feb-07 20:48 
QuestionTrayIcon Application Pin
neTo8417-Feb-07 17:06
neTo8417-Feb-07 17:06 
AnswerRe: TrayIcon Application Pin
Stefan Troschuetz17-Feb-07 20:49
Stefan Troschuetz17-Feb-07 20:49 
QuestionWindows Applications Problems in C#..please i need help..thank you.. Pin
icesha17-Feb-07 16:36
icesha17-Feb-07 16:36 
AnswerRe: Windows Applications Problems in C#..please i need help..thank you.. Pin
Christian Graus17-Feb-07 19:24
protectorChristian Graus17-Feb-07 19:24 
GeneralRe: Windows Applications Problems in C#..please i need help..thank you.. Pin
icesha17-Feb-07 19:42
icesha17-Feb-07 19:42 
GeneralRe: Windows Applications Problems in C#..please i need help..thank you.. Pin
Christian Graus17-Feb-07 20:10
protectorChristian Graus17-Feb-07 20:10 
GeneralRe: Windows Applications Problems in C#..please i need help..thank you.. Pin
icesha17-Feb-07 20:14
icesha17-Feb-07 20:14 
GeneralRe: Windows Applications Problems in C#..please i need help..thank you.. Pin
Luc Pattyn18-Feb-07 3:47
sitebuilderLuc Pattyn18-Feb-07 3:47 
QuestionC# Decompiler Pin
Eddymvp17-Feb-07 10:43
Eddymvp17-Feb-07 10:43 
AnswerRe: C# Decompiler Pin
Colin Angus Mackay17-Feb-07 11:22
Colin Angus Mackay17-Feb-07 11:22 
GeneralRe: C# Decompiler Pin
Eddymvp17-Feb-07 14:54
Eddymvp17-Feb-07 14:54 
AnswerRe: C# Decompiler Pin
Guffa17-Feb-07 15:19
Guffa17-Feb-07 15:19 
GeneralRe: C# Decompiler Pin
Ed.Poore17-Feb-07 20:01
Ed.Poore17-Feb-07 20:01 
QuestionText extraction -- This one will make you dizzy Pin
AngryC17-Feb-07 10:10
AngryC17-Feb-07 10:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.