473,320 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

C# GetType - Why does it need an instance?

Hi there,

In VB.net i can just GetType(string) to get the string type? In C# it seems
i need to have or create a non null variable and myvar.GetType(). Is there a
shorthand version of this like VB.net in C#. On a couple of occasion ive
found myself creating a throw away var just so i can gets it type which just
looks dumb.

Thanks
Richard
Apr 18 '07 #1
3 10729
Use typeof(string)

Apr 18 '07 #2
On Apr 18, 5:19 pm, "Richard Coltrane" <r...@spamsux.comwrote:
Hi there,

In VB.net i can just GetType(string) to get the string type? In C# it seems
i need to have or create a non null variable and myvar.GetType(). Is there a
shorthand version of this like VB.net in C#. On a couple of occasion ive
found myself creating a throw away var just so i can gets it type which just
looks dumb.
GetType is a keyword in VB.Net, not in C#. As James pointed out, the
C# equivalent is typeof

Apr 19 '07 #3
wa-hoo!!

Thanks

Richard

"Chris Dunaway" <du******@gmail.comwrote in message
news:11*********************@y5g2000hsa.googlegrou ps.com...
On Apr 18, 5:19 pm, "Richard Coltrane" <r...@spamsux.comwrote:
>Hi there,

In VB.net i can just GetType(string) to get the string type? In C# it
seems
i need to have or create a non null variable and myvar.GetType(). Is
there a
shorthand version of this like VB.net in C#. On a couple of occasion ive
found myself creating a throw away var just so i can gets it type which
just
looks dumb.

GetType is a keyword in VB.Net, not in C#. As James pointed out, the
C# equivalent is typeof

Apr 19 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Zhao Huang | last post by:
Hi, I'm new to python and I've come across a problem with my objects corrupting each other. class aclass: num = 0 l = ,] a = aclass()
3
by: Kelmen Wong | last post by:
Greeting, I'm working on a class managing resources (satelite). public CResMgr() { Assembly objClient = Assembly.GetCallingAssembly(); _objResMgr = new...
1
by: hazz | last post by:
"Value cannot be null.\r\nParameter name: type" is the exception thrown after the CreateInstance method below. Type t = Type.GetType(GetConfigValue("PasswordProvider")); IPasswordProvider ppdr=...
3
by: srkvellanki | last post by:
Hi all, Please give me the differences between typeof and GetType bye
6
by: Jim Bancroft | last post by:
Hi everyone, I'm having some trouble with the code below. I receive a compile-time error on the second line saying "; expected": private static void myTestFunction(long myLong) { ...
9
by: Joanna Carter \(TeamB\) | last post by:
Hi folks I am trying to assign a Delegate to an Event using reflection. I use FieldInfo.GetValue to supposedly get the field object, but casting the result to the type of the field and...
0
by: Bob | last post by:
MS offers casting success as the only solution to determine what you're looking at when you have a System.__ComObject. "t.IsAssignableFrom(o.GetType)" does not work. "t is o.GetType" does not work....
18
by: Daniel | last post by:
Hey guys I have an instance of an object say: List<Object> myList = new List<Object>(); Object myObject = new Object(); myObject.PositionVector = new Vector3(10,10,10); ...
14
by: Anoop | last post by:
Hi, I am new to this newsgroup and need help in the following questions. 1. I am workin' on a GUI application. Does C# provides Layout Managers the way Java does to design GUI? I know that it...
4
by: Chris Bordeman | last post by:
I have a DataColumn, want to derive the DbType. I can do column.GetType() but that's a system type, not a db type. How do I convert it to the corresponding type? Thanks much! Chris B.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.