none
IntPtr initialization RRS feed

  • Question

  • This may be a trivial question. I am a C++ developer, new to C#. One of the C# libraries I use has a class with one of its data variables defined as IntPtr type. It is inherently of integer type. How do I modify the value to another integer value? Thanks.

    Thursday, October 21, 2010 10:20 AM

Answers

  • IntPtr is an immutable value type so you cannot modify the value of an existing instance. You can create a new IntPtr from an existing one using the Add or Subtract methods to apply Int32 offsets. Alternatively you can use the constructor that takes an Int32 parameter to create a new instance with the specified value.
    Thursday, October 21, 2010 11:25 AM