RaouL_BennetH
10-07-2009, 16:47
Ciao a tutti :)
Stavo scrivendo questa piccola classe:
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
}
}
Inizialmente avevo pensato semplicemente:
throw ex;
Altrimenti dovrei far tornare un dizionario vuoto :mbe:
Grazie a tutti :)
RaouL.
Stavo scrivendo questa piccola classe:
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
}
}
Inizialmente avevo pensato semplicemente:
throw ex;
Altrimenti dovrei far tornare un dizionario vuoto :mbe:
Grazie a tutti :)
RaouL.