I have an generic List-Class and I want to use my Method CorrectData() from this class. At the moment I have implementated the Method CorrectData() into the class LoadListe. If I put this into the generic List then I get an compiler error CS1061.
Whats wrong?
Thanks Steffen
using System.Collections.ObjectModel;
namespace WindowsFormsGenerics
{
/// <summary>Basisklasse für alle Elemente </summary>
public class Base
{
/// <summary> Elementname </summary>
public string Name { get; set; }
/// <summary> Beschreibung </summary>
public string Description { get; set; }
}
public class Knoten : Base { }
public class OneNodeElement : Base
{
/// <summary> KnotenOne des Elementes </summary>
public Knoten KnotenOne { get; set; }
/// <summary> Schaltzustand am KnotenOne </summary>
public bool SwitchOne { get; set; }
}
public class Load : OneNodeElement
{
public void CorrectData(){}
}
public sealed class LoadListe : Liste<Load>
{
public void CorrectData()
{
foreach (Load item in this)
{
item.CorrectData();
}
}
}
public abstract class Liste<T> : Collection<T> where T : Base
{
public T GetItem(string searchsString, string parameter = "NAME")
{
return null;
}
public void CorrectData()
{
foreach (T item in this)
{
item.CorrectData();
}
}
}
}