B
Brian Tkatch
Guest
(This is more of a curiosity than anything else.) Can i use a variable (or the like) in an Of clause to specify the type?
In my case, i am using Newtonsoft Json to deserialize an object, that is, change a json string into .Net Class. For example, if i declare two types:
Public Class Moo
Public moo As String
End Class
Public Class Cow
Public cow As String
End Class
I can deserialize it via:
Dim Moocow As Moo = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Moo)("{'moo':'cow'}")
I want to know if i can do the equivalent of:
Dim Moocow As Moo = Newtonsoft.Json.JsonConvert.DeserializeObject(Of <Moocow.Class>)("{'moo':'cow'}")
I know i can do this via Select Case to use the right type, or overloading a function, once per type. What i want to know here is, can i use a variable or the like in the Of clause to specify the type, resulting in one line of code that works for all types?
Continue reading...
In my case, i am using Newtonsoft Json to deserialize an object, that is, change a json string into .Net Class. For example, if i declare two types:
Public Class Moo
Public moo As String
End Class
Public Class Cow
Public cow As String
End Class
I can deserialize it via:
Dim Moocow As Moo = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Moo)("{'moo':'cow'}")
I want to know if i can do the equivalent of:
Dim Moocow As Moo = Newtonsoft.Json.JsonConvert.DeserializeObject(Of <Moocow.Class>)("{'moo':'cow'}")
I know i can do this via Select Case to use the right type, or overloading a function, once per type. What i want to know here is, can i use a variable or the like in the Of clause to specify the type, resulting in one line of code that works for all types?
Continue reading...