J
Jon
Hi,
When I try to compile the following generic class, the compiler gives
me many errors "Cannot conver type '...' to '...'" on the lines
indicated. Besides, the C# compiler gives me errors even if I don't
declare and instantiate C_Filter_MA<Ti,Ts> in my program.
Ti and Ts should be one of {Byte, UInt16, UInt32, UInt64, SByte,
Int16, Int32, Int64, double}.
Any clue on how to be able to compile this class?
Thank you very much.
// ==============================================================
public class C_Filter_MA<Ti,Ts>
{
// ............................................................
protected Queue<Ti> Ti_queue; // Queue (FIFO) that stores the
items.
protected Ts Ts_sum; // Sum of the values stored in the
queue.
...
// ............................................................
...
// ............................................................
public void Clear()
{
...
Ts_sum =(Ts)0; // <-- Compile error.
...
} // Clear
// ............................................................
public Ti InOutData(Ti Ti_in)
{
...
Ts_sum -=(Ts)Ti_queue.Dequeue(); // <-- Compile error.
...
Ts_sum +=(Ts)Ti_in; // <-- Compile error.
...
} // InOutData
// ............................................................
} // C_Filter_MA
// ==============================================================
When I try to compile the following generic class, the compiler gives
me many errors "Cannot conver type '...' to '...'" on the lines
indicated. Besides, the C# compiler gives me errors even if I don't
declare and instantiate C_Filter_MA<Ti,Ts> in my program.
Ti and Ts should be one of {Byte, UInt16, UInt32, UInt64, SByte,
Int16, Int32, Int64, double}.
Any clue on how to be able to compile this class?
Thank you very much.
// ==============================================================
public class C_Filter_MA<Ti,Ts>
{
// ............................................................
protected Queue<Ti> Ti_queue; // Queue (FIFO) that stores the
items.
protected Ts Ts_sum; // Sum of the values stored in the
queue.
...
// ............................................................
...
// ............................................................
public void Clear()
{
...
Ts_sum =(Ts)0; // <-- Compile error.
...
} // Clear
// ............................................................
public Ti InOutData(Ti Ti_in)
{
...
Ts_sum -=(Ts)Ti_queue.Dequeue(); // <-- Compile error.
...
Ts_sum +=(Ts)Ti_in; // <-- Compile error.
...
} // InOutData
// ............................................................
} // C_Filter_MA
// ==============================================================