473,387 Members | 3,033 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,387 software developers and data experts.

typeof or System.Type.GetType

Hello C# gurus,

I would like your opinion. Who is quicker to obtain a
System.Type(): typeof() or System.Type.GetType()?

Regards,

Baccarin.
Nov 15 '05 #1
2 19549
If you know the type, then use typeof. Otherwise, if you
depend on run-time info, then you have to use GetType().

Tu-Thach
-----Original Message-----
Hello C# gurus,

I would like your opinion. Who is quicker to obtain a
System.Type(): typeof() or System.Type.GetType()?

Regards,

Baccarin.
.

Nov 15 '05 #2
Baccarin <pe***@pekus.com.br> wrote:
I would like your opinion. Who is quicker to obtain a
System.Type(): typeof() or System.Type.GetType()?


Are you really getting a Type reference that often that it's likely to
make any difference? I would use typeof if you know the type name at
compile time, as then you get compile-time checking of spelling
mistakes. If you don't know the type name at compile time, you can't
use typeof anyway.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #3

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

Similar topics

2
by: AlexB | last post by:
I have a sub routine that performs an operation on all of the controls on an ASP.NET page using the If TypeOf..Is X statement. I want to pass the class, X, in as a parameter. Is this possible? ...
4
by: ichor | last post by:
hi what is the use of the typeof keyword , and how does it differ from the GetType method. i found the GetType method useful but i fail to understand the use of the typeof method. i have tried...
3
by: srkvellanki | last post by:
Hi all, Please give me the differences between typeof and GetType bye
10
by: Jim Heavey | last post by:
I want to know if the type of data of one object is the same type as another object. The "TypeOf" function let's me find out it the object is integer or string or.... but it does not seem to allow...
1
by: Brien King | last post by:
Ok, I have three classes (The example here is extremely simplified to illustrate the problem) like this: Public Class A Public Sub DoSomething(ByVal myClass) If TypeOf myClass IS A Then ' '...
6
by: Michael C# | last post by:
What's the VB equivalent of the C# typeof() operator (it doesn't appear to be the VB "TypeOf" operator). Thanks.
11
by: Jason Kendall | last post by:
Why doesn't the new "IsNot" operator work in conjunction with 'Typeof'?
6
by: lothar.behrens | last post by:
Hi, I have some code, where I am using a variable for a given interface. One step later, using Remoting, I need Type.TypeOf("...") The following code returns Nothing, but the type above could...
2
by: Muckeypuck | last post by:
hello, i would like to write a function that takes a webcontrol type as a parameter and returns an array of controls based on the type some thing like: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.