Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27350

VS 2012 Object Type as a parameter in a function

$
0
0
How can I check if an object is of a certain type in a function. Here is my code:

Code:

    Public Function IsSerializedObjectAValidObjectType(Of ObjectType)(FileName As String) As Boolean
        Dim ObjectToCheck As New Object
        ObjectToCheck = OpenObjectFromFile(FileName)
        Return ObjectToCheck.GetType Is ObjectType
    End Function

Code:

ObjectToCheck = OpenObjectFromFile(FileName)
Gets an object from a file.

Viewing all articles
Browse latest Browse all 27350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>