473,396 Members | 1,785 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,396 software developers and data experts.

object.GetType

Hi y'all,

I am not entirely clear on how to use this method, object.GetType.
Actually, I'm quite in the dark. For what can it be used?

Given an object, is this used to promote the object to a derived class?

As an aside, how is this done? For instance, given any object as a generic
object, how do I discover its derived class and convert it to that type of
class.

Thanx,
Bill
Nov 16 '05 #1
4 3821
Bill,

GetType() returns the current 'most derived' type of the object. you
can use that method to find out the type of any object, which is
quite helpful in a lot of circumstances.

you don't need to 'discover' the derived classes type: GetType()
will return that type.

WM_HOPETHISHELPS
thomas woelfer
http://www.die.de/blog


"web1110" <we***@comcast.net> schrieb im Newsbeitrag news:IN********************@comcast.com...
Hi y'all,

I am not entirely clear on how to use this method, object.GetType.
Actually, I'm quite in the dark. For what can it be used?

Given an object, is this used to promote the object to a derived class?

As an aside, how is this done? For instance, given any object as a generic
object, how do I discover its derived class and convert it to that type of
class.

Thanx,
Bill

Nov 16 '05 #2
Could you give me a simple minded example. The question arose when I tried
this and couldn't get a successful compilation. This led me to think I was
following the wrong path.

By the way, thanks
Bill
Nov 16 '05 #3
You asked: " For instance, given any object as a generic
object, how do I discover its derived class and convert it to that type of
class."

In many cases discovering derived classes is not the best way because it
creates tight coupling between classes. Class hierarchies and interfaces
should be designed in such a way that it is transparent to the caller what
exact subtype is called.

Leonid Finis.

"web1110" <we***@comcast.net> wrote in message
news:IN********************@comcast.com...
Hi y'all,

I am not entirely clear on how to use this method, object.GetType.
Actually, I'm quite in the dark. For what can it be used?

Given an object, is this used to promote the object to a derived class?

As an aside, how is this done? For instance, given any object as a
generic
object, how do I discover its derived class and convert it to that type of
class.

Thanx,
Bill

Nov 16 '05 #4
I understand. I am curious as to how to accomplish this,nothing more. I
don't foresee a need, just a lack of knowledge.
Nov 16 '05 #5

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

Similar topics

1
by: Bijay Kumar | last post by:
Hi Guys, I was going through the source code of Object.cs in rotor. What I found is Equals() implemented as follows: public extern virtual bool Equals(Object obj); What I don't...
1
by: Horst Klein | last post by:
I want set different properties of any object at runtime. With the Function below it works well, but not perfect Is there a way to set properties of any type with its value Principle...
1
by: Dave | last post by:
In Exceptional C++, the following code snippet appears at the bottom of page 197: template<class T> class Array : private ArrayBase, public Container { typedef Array AIType; public: Array(...
9
by: Yan Vinogradov | last post by:
Hi, Turns out it's possible to spoof another type with Object.GetType method. If you do this: namespace N { class C { public new Type GetType() { return (String.Empty.GetType()); }
7
by: James CC | last post by:
Hi there, I have a function, converted from VB, that is passed an object, and sets it up. The object passed is either a ListBox or a ComboBox. The code checks to make sure that the object passed...
5
by: Matthew | last post by:
I have a nice little Sub that saves data in a class "mySettings" to an XML file. I call it like so: Dim mySettings As mySettings = New mySettings mySettings.value1 = "someText" mySettings.value2...
3
by: sista via DotNetMonster.com | last post by:
hi.. just wondering what does this error means? here's my vb code: Imports System.Web.Security Imports System.Data Imports System.Data.OleDb Public Class dpitem Inherits System.Web.UI.Page
16
by: anonymous.user0 | last post by:
The way I understand it, if I have an object Listener that has registered as a listener for some event Event that's produced by an object Emitter, as long as Emitter is still allocated Listener...
3
by: Tony Johansson | last post by:
Hello!! You may correct me if I have made any wrong assumptions. Below I have some simple classes. When you have this t.ToString() below it's the ToString() method in Object class that is...
10
by: Arpan | last post by:
Consider the following code that adds a table to a DataSet dynamically: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) 'Create an empty DataSet Dim dSet As...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.