Interfaces with structs, by reference using Generics
- by Fraga
I can't pass by reference an interface with a struct in it,
what am I doing wrong?
Here is the example code:
class Processor<T>
     where T : new()
{
    public Processor()
    {
        Data = new T();
    }
    public T Data;
}
class PeriodsProcessor : Processor<Periods>
{
    public PeriodsProcessor()
    {
        DataBase DB = new DataBase();
        Console.WriteLine(Data.Value);
        DB.ModifyData<Period>(Data);
        Console.WriteLine(Data.Value);
        Console.ReadLine();
    }
}
public class Period
{
    public string Name;
}
public interface IDataTable<T>
{
    string Value { get; set; }
    T Filter { get; set; }
}
[Serializable]
public struct Periods : IDataTable<Period>
{
    public string Value { get; set; }
    public Period Filter { get; set; }
}
public class DataBase
{
    public void ModifyData<T>(IDataTable<T> data) 
        where T : new()
    {
        data.Value = "CHANGE";
    }
}
class Program
{
    static void Main(string[] args)
    {
        PeriodsProcessor PeriodsProcessor = new PeriodsProcessor();
    }
}