0
我有一個使用泛型類型下面的代碼:在xs.Serialize(fs,T)上使用泛型T獲取錯誤;
public static bool SaveConfigurationData<T>(string filePath)
{
bool returnVal = false;
try
{
// Create and XmlSerializer to serialize the data to a file
XmlSerializer xs = new XmlSerializer(typeof(T));
string textSerialized = string.Empty;
using (FileStream fs = new FileStream(filePath, FileMode.Create))
{
xs.Serialize(fs, T);
}
returnVal = true;
}
catch (Exception ex)
{
returnVal = false;
}
return returnVal;
}
但即時得到就行了以下錯誤:xs.Serialize(fs, T);
任何線索?
仔細看看'xs.Serialize(fs,T);' – JanDotNet