天天看點

How to: Define a Conversion Operator [msdn]Example

because of my project, learned something about vb.net. and now by chance, find this stuff. it's pretty cool.

visual studio 2005

<a href="http://msdn.microsoft.com/library/yf7b9sy7(en-us,vs.80).aspx">other versions</a>

if you have defined a class or structure, you can define a type conversion operator between the type of your class or structure and another data type (such as integer, double, or string).

defining an operator on a class or structure is also called overloading the operator.

the following example defines conversion operators between a structure called digit and a byte.

<a>vb</a>

<a href="http://msdn.microsoft.com/library/yf7b9sy7(en-us,vs.80).aspx">c#</a>

<a href="http://msdn.microsoft.com/library/yf7b9sy7(en-us,vs.80).aspx">c++</a>

<a href="http://msdn.microsoft.com/library/yf7b9sy7(en-us,vs.80).aspx">f#</a>

<a href="http://msdn.microsoft.com/library/yf7b9sy7(en-us,vs.80).aspx">jscript</a>

<a href="http://msdn.microsoft.com/library/yf7b9sy7(en-us,vs.80).aspx">copy</a>

you can test the structure digit with the following code.

How to: Define a Conversion Operator [msdn]Example

歡迎加群互相學習,共同進步。qq群:ios: 58099570 | android: 330987132 | go:217696290 | python:336880185 | 做人要厚道,轉載請注明出處!http://www.cnblogs.com/sunshine-anycall/archive/2010/12/22/1913789.html