Mega Code Archive

 
Categories / VB.Net / Reflection
 

Create pointer and ByRef types to use when you define method parameters

Imports System Imports System.Reflection Imports System.Runtime.InteropServices Public Class Example     Public Shared Sub Test(ByRef x As Integer, <Out> ByRef y As Integer)     End Sub     Public Shared Sub Main()         Dim nums() As Integer = {1, 1, 2, 3, 5, 8, 13}         Dim t As Type = nums.GetType()         Console.WriteLine("HasElementType is '{0}' for array types.", t.HasElementType)         t = GetType(Example).MakePointerType()         Console.WriteLine("HasElementType is '{0}' for pointer types.", t.HasElementType)         t = GetType(Example).MakeByRefType()         Console.WriteLine("HasElementType is '{0}' for ByRef types.", t.HasElementType)     End Sub End Class