Accessin Members With Pointer- Arrow Operator C# with Example



Accessin Members With Pointer- Arrow Operator C# with Example

 	using System;

	namespace CSharpClass
	{
		public struct Coordinate
		{
			public int x, y;
		}
		
		class UsingPointers
		{
			unsafe public static void UsingArrowOperator()
			{
				Coordinate pixel = new Coordinate();
				Coordinate* pixelPtr = &(pixel);
				(*pixelPtr).x = 134;
				(*pixelPtr).y = 34;
				
				Console.WriteLine("Pixel Position: {0},{1}", pixelPtr->x, pixelPtr->y);
			}

			static void Main()
			{
				unsafe
				{
					UsingArrowOperator();
				}
			}
		}
	} 

0 Comment's

Comment Form

Submit Comment