Casting Between Data Types in C#
Posted
by Jimbo
on Stack Overflow
See other posts from Stack Overflow
or by Jimbo
Published on 2010-04-28T10:46:36Z
Indexed on
2010/04/28
10:53 UTC
Read the original article
Hit count: 327
I have (for example) an object of type A that I want to be able to cast to type B (similar to how you can cast an int
to a float
)
Data types A and B are my own.
Is it possible to define the rules by which this casting occurs?
Example
int a = 1;
float b = (float)a;
int c = (int)b;
© Stack Overflow or respective owner