mardi 8 septembre 2015

Name of variable assigned in .NET

VB2010. Not even sure if this is possible but for debugging purposes I want to print out the name of the variable that was assigned to a master variable (both being classes).

        Dim mstTripClass As Trip = Nothing
        Select Case sc
            Case "0"
                mstTripClass = driver.BusinessTrip
            Case "7", "8"
                mstTripClass  = driver.LeisureTrip
            Case "10"
                mstTripClass = driver.OtherTrip
            Case Else
                Throw New Exception("Invalid trip class")
        End Select

        Debug.Print("Trip class=" & mstTripClass.GetType.ToString)

This prints out

        Trip class=MyCompany.MyDept.MyApp.Trip

What i would like to print out is something like:

        Trip class=BusinessTrip

I'm not even sure how to search for this type of thing. I searched for reflection but came up empty.





Aucun commentaire:

Enregistrer un commentaire