I think I traded posts similar to this topic with john (jmcilhinney) back in 2006-2007, but I can't find them anymore.
I'm trying to get my head wrapped around Generics....again. My goal is to create a public function that resides in a module that is used to convert data in one format to another.
For example: I would call the function by passing it a string date such as "mmddyyyy" with an integer code of 2. That tells me what I am receiving and I should return the same string as "mm/dd/yy".
I could also call the same function by passing a string such as "mm/dd/yy" with an integer code of 27. That tells me I am receiving a string and should return a date object that matches that day.
So far I think I should be doing something like this:
The problem is, I don't really understand what this code is setting me up for, or how I would proceed to code the function without losing Type safety.
Can anyone help get me on the right track?
Thanks in advance!
I'm trying to get my head wrapped around Generics....again. My goal is to create a public function that resides in a module that is used to convert data in one format to another.
For example: I would call the function by passing it a string date such as "mmddyyyy" with an integer code of 2. That tells me what I am receiving and I should return the same string as "mm/dd/yy".
I could also call the same function by passing a string such as "mm/dd/yy" with an integer code of 27. That tells me I am receiving a string and should return a date object that matches that day.
So far I think I should be doing something like this:
vb.net Code:
Module Cvsn Public Function DoCvsn(Of T)(ByVal TheInput As T, ByVal CvsnCode As Integer) As T End Function End Module
The problem is, I don't really understand what this code is setting me up for, or how I would proceed to code the function without losing Type safety.
Can anyone help get me on the right track?
Thanks in advance!