You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I create a class and give it an implicit conversion operator:
public SomeClass(string value)
{
// ...
}
public static implicit operator SomeClass(string value)
{
return new SomeClass(value);
}
It'd be nice to also be able to provide an array converter as well, e.g.
public static implicit operator SomeClass[](string[] values)
{
return values.Select(value => new SomeClass(value)).ToArray();
}
Currently, the implicit conversion won't happen automatically for the array (even with the singular implicit converter defined), so making an extension to the other type to provide a helper seems to be the only route but a bit messier.
Also found similar questions for this process dating back to 2010 here.
The text was updated successfully, but these errors were encountered:
If I create a class and give it an implicit conversion operator:
It'd be nice to also be able to provide an array converter as well, e.g.
Currently, the implicit conversion won't happen automatically for the array (even with the singular implicit converter defined), so making an extension to the other type to provide a helper seems to be the only route but a bit messier.
Also found similar questions for this process dating back to 2010 here.
The text was updated successfully, but these errors were encountered: