这真的让我很困惑。我已经尝试删除只读的,更改名称..我在这里做错了什么?
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\Ar\Ar\ViewModel\Workspaces\MaterialCatalogBase.cs 9 18 Ar
编辑2:
即使我如下更改类,我仍然会收到错误:
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();
}
另外,我忘了提到由于某种原因我得到了两个(完全相同的错误)..?