In C#, the typeof keyword can be used to get a type of the class. This does
not require object to be created first. However O am not sure how do the
same thing in vb. I don't want to create the object just to get its type. I
would appreciate if any one can can show me how to do this in vb.net.
Thanks.
Raghu/.. 6 6674
Raghu,
Use the GetType operator, instead of the GetType method.
Dim t As Type = GetType(Integer)
If you want to check an object variable for a specific type you can use the
TypeOf Is operator.
Dim o As Object
If TypeOf o Is Integer Then
' we have an Integer here!
End If
Hope this helps
Jay
"Raghu" <Ra***@nospamzzzqcsi.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... In C#, the typeof keyword can be used to get a type of the class. This
does not require object to be created first. However O am not sure how do the same thing in vb. I don't want to create the object just to get its type.
I would appreciate if any one can can show me how to do this in vb.net.
Thanks. Raghu/..
* "Raghu" <Ra***@nospamzzzqcsi.com> scripsit: In C#, the typeof keyword can be used to get a type of the class. This does not require object to be created first. However O am not sure how do the same thing in vb. I don't want to create the object just to get its type. I would appreciate if any one can can show me how to do this in vb.net.
GetType Operator
<URL:http://msdn.microsoft.com/library/en-us/vblr7/html/vaoprgettype.asp>
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
I did not make my self clear. I can write following code in csharp:
public class MyAgent {
...
}
Type t = typeof(MyAgent);
When I write following vb.net code, it fails to compile:
Public Class MyAgent
....
End Class
Dim t as Type
t = Type.GetType(MyAgent)
However I can write following code, but it does not catch compile time error
if class name is changed:
t = Type.GetType("MyAgent")
Any ideas?
Thanks.
Raghu/..
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2o************@uni-berlin.de... * "Raghu" <Ra***@nospamzzzqcsi.com> scripsit: In C#, the typeof keyword can be used to get a type of the class. This
does not require object to be created first. However O am not sure how do the same thing in vb. I don't want to create the object just to get its
type. I would appreciate if any one can can show me how to do this in vb.net.
GetType Operator <URL:http://msdn.microsoft.com/library/en-us/vblr7/html/vaoprgettype.asp>
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
* "Raghu" <Ra***@nospamzzzqcsi.com> scripsit: I did not make my self clear. I can write following code in csharp:
public class MyAgent { ... }
Type t = typeof(MyAgent);
When I write following vb.net code, it fails to compile:
Public Class MyAgent ... End Class
Dim t as Type
t = Type.GetType(MyAgent)
However I can write following code, but it does not catch compile time error if class name is changed:
t = Type.GetType("MyAgent")
Use 't = GetType(MyAgent)'.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Raghu,
I gave you an example, Herfried gave you the documentation.
Use the GetType operator, not the Type.GetType method! Dim t as Type
t = GetType(MyAgent)
Hope this helps
Jay
"Raghu" <Ra***@nospamzzzqcsi.com> wrote in message
news:Oj****************@TK2MSFTNGP12.phx.gbl... I did not make my self clear. I can write following code in csharp:
public class MyAgent { ... }
Type t = typeof(MyAgent);
When I write following vb.net code, it fails to compile:
Public Class MyAgent ... End Class
Dim t as Type
t = Type.GetType(MyAgent)
However I can write following code, but it does not catch compile time
error if class name is changed:
t = Type.GetType("MyAgent")
Any ideas?
Thanks. Raghu/..
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:2o************@uni-berlin.de... * "Raghu" <Ra***@nospamzzzqcsi.com> scripsit: In C#, the typeof keyword can be used to get a type of the class. This does not require object to be created first. However O am not sure how do
the same thing in vb. I don't want to create the object just to get its type. I would appreciate if any one can can show me how to do this in vb.net.
GetType Operator
<URL:http://msdn.microsoft.com/library/en-us/vblr7/html/vaoprgettype.asp> -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Thank you guys.
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ep**************@TK2MSFTNGP12.phx.gbl... Raghu, I gave you an example, Herfried gave you the documentation.
Use the GetType operator, not the Type.GetType method!
Dim t as Type
t = GetType(MyAgent)
Hope this helps Jay
"Raghu" <Ra***@nospamzzzqcsi.com> wrote in message news:Oj****************@TK2MSFTNGP12.phx.gbl... I did not make my self clear. I can write following code in csharp:
public class MyAgent { ... }
Type t = typeof(MyAgent);
When I write following vb.net code, it fails to compile:
Public Class MyAgent ... End Class
Dim t as Type
t = Type.GetType(MyAgent)
However I can write following code, but it does not catch compile time error if class name is changed:
t = Type.GetType("MyAgent")
Any ideas?
Thanks. Raghu/..
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:2o************@uni-berlin.de... * "Raghu" <Ra***@nospamzzzqcsi.com> scripsit: > In C#, the typeof keyword can be used to get a type of the class.
This does > not require object to be created first. However O am not sure how do the > same thing in vb. I don't want to create the object just to get its type. I > would appreciate if any one can can show me how to do this in
vb.net. GetType Operator
<URL:http://msdn.microsoft.com/library/en-us/vblr7/html/vaoprgettype.asp> -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Timo J |
last post by:
Hi - Im sitting and trying to understand this OOP - and need to create a
class wich can do the following..
ShowBlocks() - Displays the data wich is inside it - If empty creates a form
wich sends the info back to the Object, wich show the stuff..
AddBlock( $type ) - Creates an empty blok - wich is addet to a blocks area
object...( Or...
|
by: Fuzzyman |
last post by:
Hello,
To create a classic (old style) class, I write :
class foo:
pass
To do the equivalent as a new style class, I write :
class foo(object):
|
by: Daylor |
last post by:
first of all , PLEASE,say somthing..about my post.
any reply will be nice to read.
i have vb.app , with 2 appdomains.
(now, in the next section , ill write "appdomain create" ,means a code in
the appdomain is creating )
appdomain2 call appdomain 1 to create object of type "CCar" (the param is
string )
the appdomain1 creating a object...
|
by: Martin |
last post by:
I'd like to be able to get the name of an object instance from within
a call to a method of that same object. Is this at all possible?
The example below works by passing in the name of the object instance
(in this case 'myDog'). Of course it would be better if I could
somehow know from within write() that the name of the object instance
was...
|
by: sneill |
last post by:
How is it possible to take the value of a variable (in this case,
MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name?
In the following example I want 'oIcon' object to have the properties:
mode1, mode2, and mode3.
This seems simple but I can't quite figure it out...
Any ideas anyone?
| |
by: Kevin Prichard |
last post by:
Hi all,
I've recently been following the object-oriented techiques discussed
here and have been testing them for use in a web application. There is
problem that I'd like to discuss with you experts.
I would like to produce Javascript classes that can be "subclassed"
with certain behaviors defined at subclass time. There are plenty of...
|
by: chippy |
last post by:
I am finding that when I use the cloneNode method to copy an HTML
element that contains a <script> tag, the contents of the <script> tag,
(ie. the javascript) are removed.
If I do this:
var form1 = document.getElementById(sID).firstChild.cloneNode(true);
alert(form1.outerHTML);
I can see the empty <script> tags. I am wondering if there...
|
by: lk |
last post by:
I need some help regarding the mechanism to put in place to be able to
dynamically update a remote object when the assembly where it is defined is
modified, and this whitout having service interruption.
Basically what I'm missing is how do we re-expose a remote object when
assembly has changed, and this without any interruption to the...
|
by: SunnyDrake |
last post by:
HI!
I wrting some program part of it is XML config parser which contains
some commands(for flexibility of engenie).
how do i more simple(if it possible not via System.Reflection or
System.CodeDom.CodeCastExpression)
__problem typecast #1
Desc:i do needed checks but data/commands in XML is dynamic and i don't
wanna fix C# code again and...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |