|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Sep 2004
Messaggi: 3967
|
[C#]Restituzione valore in caso eccezione
Ciao a tutti
Stavo scrivendo questa piccola classe: Codice:
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace DictionaryResource
{
public class DictionaryLoader
{
public static IDictionary<string, string> UserList(string fileName)
{
IDictionary<string, string> uList = new Dictionary<string, string>();
try
{
StreamReader sr = new StreamReader(fileName);
string valore ;
while((valore = sr.ReadLine()) != null)
{
string[] col = valore.Split(',');
uList.Add(col[0], col[1]);
}
sr.Close();
return oList;
}
//qui il mio dubbio:
catch(IOException ex)
{
//se catturo 'ex', cosa devo far restituire?
}
catch(Exception ex)
{
//stesso discorso
}
}
Codice:
throw ex; ![]() Grazie a tutti RaouL.
__________________
Dai wafer di silicio nasce: LoHacker... il primo biscotto Geek
|
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Jun 2007
Città: Milano
Messaggi: 413
|
Secondo me non hai tante alternative: se devi mettere un
Codice:
throw ex; Se invece vuoi gestire le eccezioni, secondo me un possibile valore di ritorno potrebbe essere il null. Ciao |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 21:34.




















