In the book "Essential Guide to Manged Extensions for C++" page 55 "In MC++,
class that are meant to be created on the stack are called value types. In
this capter you will learn how to create value types, convert them to gc
classes via boxing, and implent interfaces by deriving a value type from
them." On the next page it says "A value type is declared with the keyword
__value followed by class or stuct... for example:
"#using <mscorlib.dll>
__value class Fraction
{
....
}
The value type Fraction can then be created on the stack:
int main()
{
Fraction f(1,2);
}
....
So according to this book (written by people on the MC++ compiler team) it
indicates they can be created in MC++. But I take it not possible in C#
unless I create a struct?
As well, is it a compiler trick that I can say
int i = 10;
int j; j=10;
instead of
int i = new System.Int32();
?
Thanks,
Shawn
"Richard A. Lowe" <ch*****@yumspamyumYahoo.com> wrote in message
news:O4**************@TK2MSFTNGP12.phx.gbl...
Yes, just create a struct. Structs in C# are value types.
Richard
--
Veuillez m'excuser, mon Français est très pauvre. Cependant, si vous
voyez mauvais C #, c'est mon défaut!
"Shawn B." <le****@html.com> wrote in message
news:ey**************@TK2MSFTNGP10.phx.gbl... Greetings,
Is it possible to create a custom ValueType object in C#? Or must I use
managed C++ for that?
Thanks,
Shawn