Hello, I faced the need to force one type to another InputData = (TIn) InData , where the aggregate type TIn is used as the type for casting
public class SerialPortExhangeBehavior<TIn> { public TIn InData { get; set; } private async Task ExchangeService(MasterSerialPort port, CancellationToken ct) { //принудительно приведение к типу TIn var writeProvider = new PanelMg6587WriteDataProvider() {InputData = (TIn)InData}; } } class PanelMg6587WriteDataProvider : IExchangeDataProvider<UniversalInputType, Mg6587Output> { public UniversalInputType InputData { get; set; } public Mg6587Output OutputData { get; } } When creating SerialPortExhangeBehavior I close it with the type UniversalInputType
var SpExhBehavior = new SerialPortExhangeBehavior<UniversalInputType>(); And I would like to forcefully convert InputData = (TIn)InData . Even if an exception occurs if the types are not reducible.
please help !!!