Given the following class :
public class DataPair{ public string Key { get; set; } public object Value { get; set; } public DataPair(string key, object value) { Key = key; Value = value; } }
Is it possible to implement something like
public static implicit operator DataPair(dynamic value) { return new DataPair(value.Key, value.Value); }
Therefore, I can create a new instance this way
DataPair myInstance = {"key", "value"};
constructor c # dynamic implicit-conversion
Kingkerosin
source share