这我百思不得其解。 我试着去掉只读,更改名称..我在做什么错在这里?
public abstract class CatalogBase<T> where T : class
{
protected readonly String DataPath;
protected readonly XmlSerializer Serializer;
private readonly XmlSerializerNamespaces _namespaces;
protected CatalogBase(String dataPath)
{
DataPath = dataPath;
Serializer = new XmlSerializer(typeof (T));
_namespaces = new XmlSerializerNamespaces();
_namespaces.Add(String.Empty, String.Empty);
}
public virtual void Write(T obj)
{
var streamWriter = new StreamWriter(DataPath);
Serializer.Serialize(streamWriter, obj, _namespaces);
streamWriter.Close();
}
public abstract IDictionary<String, T> Read();
}
编辑:
警告:
警告1 'Ar.ViewModel.Workspaces.MaterialCatalogBase':基类型'Or.Files.CatalogBase'是不符合CLS C:_Center_Work_Programming_Cs \氩\氩\视图模型\工作区\ MaterialCatalogBase.cs 9 18氩
EDIT2:
即使我改变类下面我仍然得到错误:
public abstract class CatalogBase<T> where T : class
{
protected readonly String DataPath;
protected readonly XmlSerializer Serializer;
private readonly XmlSerializerNamespaces namespaces;
protected CatalogBase(String dataPath)
{
DataPath = dataPath;
Serializer = new XmlSerializer(typeof (T));
namespaces = new XmlSerializerNamespaces();
namespaces.Add(String.Empty, String.Empty);
}
public virtual void Write(T obj)
{
var streamWriter = new StreamWriter(DataPath);
Serializer.Serialize(streamWriter, obj, namespaces);
streamWriter.Close();
}
public abstract IDictionary<String, T> Read();
}
另外,我忘了提,我得到两个(完全相同的错误),由于某种原因..?