An expression of the form,
x->y
(*x).y
The -> operator can be used only in code that is marked as unsafe(msdn link).
The -> operator cannot be overloaded.
// compile with: /unsafe
//To compile unsafe code, you must specify the /unsafe compiler option.
//Unsafe code is not verifiable by the common language runtime.
struct Point
{
public int x, y;
}
class MainClass12
{
unsafe static void Main()
{
Point pt = new Point();
Point* pp = &pt;
pp->x = 123;
pp->y = 456;
Console.WriteLine("{0} {1}", pt.x, pt.y);
}
}
/*
Output:
123 456
*/
More references about unsafe and c# helpful keywords are below... (source :msdn)
No comments:
Post a Comment