Implicit conversion of arrays

  • Thread starter The Last Danish Pastry
  • Start date
T

The Last Danish Pastry

If I have two types, t1 and t2, say, I can write an implicit
conversion operator from t1 to t2.

Can I write implicit conversion operator from t1[] to t2[]?

I don't think I can... but, if not, what is the "next nicest thing"?
 
T

The Last Danish Pastry

If I have two types, t1 and t2, say, I can write an implicit
conversion operator from t1 to t2.

Can I write implicit conversion operator from t1[] to t2[]?

I don't think I can... but, if not, what is the "next nicest thing"?

I should have mentioned that I am talking about C#.
 
L

Lasse Vågsæther Karlsen

The said:
If I have two types, t1 and t2, say, I can write an implicit
conversion operator from t1 to t2.

Can I write implicit conversion operator from t1[] to t2[]?

I don't think I can... but, if not, what is the "next nicest thing"?

I should have mentioned that I am talking about C#.

If you're using .NET 3.5, you could write an extension method.

If not, then you'll have to just write a static method somewhere.
 
B

Barry Kelly

The said:
If I have two types, t1 and t2, say, I can write an implicit
conversion operator from t1 to t2.

Can I write implicit conversion operator from t1[] to t2[]?

I don't think I can... but, if not, what is the "next nicest thing"?

What are you using the arrays for?

Would it make sense to wrap them in a (perhaps generic) class or struct
with an indexing operator ('this' property)? You can add implicit
conversions to classes and structs.

-- Barry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top