|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
What's the VB equivalent of the C# typeof() operator (it doesn't appear to
be the VB "TypeOf" operator). Thanks. "Michael C#" <x**@abcdef.com> wrote in message news:3bp2e.9673$Z24.3939@fe12.lga... In C#,> What's the VB equivalent of the C# typeof() operator (it doesn't appear to be the VB "TypeOf" operator). Type t = typeof( String); In VB.NET, Dim t As Type = GetType( String); Derek Harmon Some of the same keywords have deceptively similar, but different, meanings
between VB and C#: VB’s global GetType method is equivalent to C#’s typeof operator, VB’s TypeOf–Is operator is equivalent to C#’s “is†operator, and of course, "Is" in VB is "==" in C#... David Anton www.tangiblesoftwaresolutions.com Home of the Instant C# VB.NET to C# converter and the Instant VB C# to VB.NET converter Show quoteHide quote "Michael C#" wrote: > What's the VB equivalent of the C# typeof() operator (it doesn't appear to > be the VB "TypeOf" operator). Thanks. > > > Michael,
As the others suggest the GetType keyword is equivalent to C#'s typeof keyword. Not to be confused with the Type.GetType method/function. The GetType keyword expects an identifier, while Type.GetType expects a String. Dim t1 As Type = GetType(Integer) Dim t2 As Type = Type.GetType("System.Int32") For known types I find the GetType keyword is better as you receive compile errors if you miss type the identifier. I reserve Type.GetType for types that are only known at runtime, such as ones read from my app.config or XML schema files. Hope this helps Jay Show quoteHide quote "Michael C#" <x**@abcdef.com> wrote in message news:3bp2e.9673$Z24.3939@fe12.lga... | What's the VB equivalent of the C# typeof() operator (it doesn't appear to | be the VB "TypeOf" operator). Thanks. | |
http://www.harding.edu/USER/fmccown/WWW/vbnet_csharp_comparison.html
;-) Michael C# wrote: Show quoteHide quote >What's the VB equivalent of the C# typeof() operator (it doesn't appear to >be the VB "TypeOf" operator). Thanks. > > > >
Why have a DBNull?
vb.net windows deployment Process.Start("Winword.exe") problem OutOfMemory exception loading ZIP or JPEG compressed TIFs from file Outlook.Application is not defined. PIA installed and setup correctly. CSV Separator RowFilter and DataColumn Named as Number Error in implementing interface Property I'd like to get an event each time the cursor stops moving. Upgrading .NET Framework v1.0 to v1.1 |
|||||||||||||||||||||||