Tuesday, May 29, 2018

View unsafe pointer as an array in C# watch window

Introduction

MS visual studio C# watch window does not support size specifier for pointer to view it as an array whereas c++ watch window does it.

Using the code

Refer below image for the unsafe fuction which receives the pointer arguments like "float * Vertices". We can use "Vertices,10" in C++ watch window to view the contents of the pointer. How to do that in C#??
Step 1: Immediate window
Declare a float array in immediate window as the following image.
Step2: Watch windowType the following line in watch window.
Marshal.Copy((IntPtr)Vertices, fVerticesArray, 0, noVertices)

After the expression is evaluated in the watch window, type the variable name which we declared in immediate window. Expand the variable to view the contents of the pointer. That's all. :)



2 comments:

  1. This is not related to AngularJs. Anyway good info.

    ReplyDelete

  2. Nice Blog , This is what I exactly Looking for , Keep sharing more blog .Remote Angularjs Developer in India

    ReplyDelete

Whats new in Angular 8

Angular 8 was released in May 2019 and  th e key features of angular 8 are as follows in brief, Differential loading Dynamic imports ...