Possible duplicate:
Is there a way to define an implicit conversion operator in VB.NET?
I donβt remember ever seeing or hearing about anyone doing this; but now I'm in a situation where, in my opinion, it would be incredibly useful to define my own "type conversion" for my class.
As an example, let's say I have my own class, AwesomeDataManager. It does not inherit from a DataTable, but it stores data similarly to a DataTable. I could say: "myDataTable = CType (MyAwesomeDataManager, DataTable)" and make it execute some code inside my class, which will return a populated DataTable.
Of course, I could do something like "MyAwesomeDataManager.GetDataTable", but for the sake of integration with the existing code base, I would like to avoid it.
source share