How do I get address of this pointer?
Add-Type @"
using System;
public class Car
{
private string model;
private int topSpeed;
public Car(string model, int topSpeed)
{
this.model = model;
this.topSpeed = topSpeed;
}
public string MakeAndTopSpeed()
{
return ("The top speed of the " + model + " is " + topSpeed + " mph ");
}
}
"@
I ran this code in sequence.
$car = [Car]::new("Corvette", 188)
PS C:\Windows\System32\WindowsPowerShell\v1.0\en-US S
$carPointer = $car.GetType().MakePointerType()
PS C:\Windows\System32\WindowsPowerShell\v1.0\en-US
$carPointer
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
False False Car*
PS C:\Windows\System32\WindowsPowerShell\v1.0\en-US S
$carRef = $car.GetType().MakeByRefType()
PS C:\Windows\System32\WindowsPowerShell\v1.0\en-US
$carRef
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
False False Car&
PS C:\Windows\System32\WindowsPowerShell\v1.0\en-US S
$carPointerRef = $carPointer.MakeByRefType()
PS C:\Windows\System32\WindowsPowerShell\v1.0\en-US
$carPointerRef
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
False False Car*&
I just want to know how to get Pointer address? You can see Car pointer object Car*
It appeared like a address when I used pointer with
$carPointerRef = $carPointer.MakeByRefType()
it displays as Car*& is that pointer address? Its actually a runTimeType
this display two of the object types
$carPointer.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
False False RuntimeType System.Reflection.TypeInfo
PS C:\Windows\System32\WindowsPowerShell\v1.0\en-US S
$carPointerRef.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
False False RuntimeType System.Reflection.TypeInfo