Good stuff, thanks PD! To review... dont use CType because its VB6 legacy reach-back (as us net-admins would say ). For my traditional C# casting I need to:
Dim x as ObjectType
x = DirectCast(y, ObjectType)
x.DoWhatever()
C# equiv (why I really like C#):
((ObjectType)x).DoWhatever();
And if I need numbers
Dim i as Integer = Integer.Parse(str)
-or-
Dim i as Interger = Convert.ToInt32(str)
I actually found that very simple to read, a lot cleaner than 3 lines of code; direct and to the point. Maybe its because Im use to do it that way, which from what Ive seen in code examples is the preferred C# way, thats how I got into doing it. But IMHO (in my humble opinion) I think thats easier (one line crumpled together instead of three lines). Guess its really semantics, but Im curious as to others thoughts on what coding style they prefer and if anyone knows what M$ recommends. Thanks for the help though, I did learn something from it.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.