Sorry guys! i am so into the code! that i forgot to put the compiler errors.
Here is a new version of the code simplified!
And this are the errors:
Error 1 The best overloaded method match for 'IWeird.DataBase.ModifyData(ref IWeird.IDataTable)' has some invalid arguments
Error 2 Argument '1': cannot convert from 'ref IWeird.Periods' to 'ref IWeird.IDataTable'
The problem: I can't pass by reference an interface with a struct in it, what am I doing wrong?
Here is the new example code:
class PeriodsProcessor
{
public PeriodsProcessor()
{
Periods Data = new Periods();
DataBase DB = new DataBase();
Console.WriteLine(Data.Value);
DB.ModifyData(ref Data);
Console.WriteLine(Data.Value);
Console.ReadLine();
}
}
public interface IDataTable
{
string Value { get; set; }
}
public struct Periods : IDataTable
{
public string Value { get; set; }
}
public class DataBase
{
public void ModifyData(ref IDataTable data)
{
data.Value = "CHANGE";
}
}
class Program
{
static void Main(string[] args)
{
PeriodsProcessor PeriodsProcessor = new PeriodsProcessor();
}
}