On Wednesday, November 21, 2012 12:57:57 Jack Applegame wrote: > But sometimes ref becomes a part of type. For example "void > delegate(ref int)" and "void delegate(int)" are different types. > Is it possible to cast from one to another safely? For example:
That's because ref is being used on a function parameter. That gives the function a different type, but you can't just use ref int by itself. As I said, it's only applicable to function parameters, return types, and foreach loop variables. > void foo(ref int); > void function(int) fp; > fp = cast(typeof(fp)) foo; /// is it safe??? No, it's not safe. - Jonathan M Davis