What's Difference Between 'typeof' And 'GetType'
Oct 5, 2009What's the difference between "typeof" and "getType"?
View 3 RepliesWhat's the difference between "typeof" and "getType"?
View 3 RepliesI have a DataGridViewCell object and I need to find out if its a string.
If row.Cells(cellIndex).ValueType Is "".GetType() Then
or
If row.Cells(cellIndex).ValueType Is Type.GetType("System.String") Then
I've got a method I'm trying to translate from c# to vb, goes something like this .. x.For(typeof(IRepository<>)).Use(typeof(Repository<>)); VB doesn't seem to like the idea of a IRepository(Of ) ... what's the syntax on that?
View 1 RepliesI am writing a .NET DLL to iterate through all controls in the a VB6 Form passed byref.So far it seems to work VB.NET code:[code]but the TypeOf operator does not work. Is there another way to find the type of control?
View 2 RepliesI am working on a parser for a serial data protocol. I have an overarching Packet class, a couple sub-classes such as CommandPacket and StatusPacket, and then a few sub-classes of each of those:
[Code]..
While I don't think it is entirely relelvant to the discussion, I am doing this in VB.NET. There is also a similar (but not quite the same) question posted here: Java - subclass validation design pattern
I am trying to write code as the following-
For Each ControlObject As Control In Me.Controls
Select Case TypeOf ControlObject
Case TextBox
[code]....
But it says that "Is expected" after the second line. Is there any technique to do it?
I'm converting some C# code to vb, and (having had some help from the community here already) have encountered another problem. [code] SurveyQ is a class I'm referring to. Converting the type doesn't seem to work. I've figured that I can't use "=" when converting types and have got this as far as: [code] but I now get errors on the GetType(SurveyQ) part, with the error "Keyword does not name a type".
View 2 RepliesI am making a function to create a dataTable but I have problemt with the getType() of the columns
Public Shared Function createDTable(strArray as string, separator as string) as dataTable
Dim newArray as new arrayList(stringToArray(strArray,","))
[Code].....
I have a very simple problem where I have a MyList As List(Of MyBaseClass) but and a couple of MySub(ByVal Dummy As MyDerivedClassA)/MySub(ByVal Dummy As MyDerivedClassB). So I want to do the following ...
For Each MyInstance As MyBaseClass In MyList
MySub(DirectCast(MyInstance, MyInstance.GetType())
...
[code].....
I'm trying register presenters with Windsor using the convention based method but trying to do this in VB.NET, but the problem is it does not want to compile this statement:
Dim type = GetType(AbstractPresenter(Of))
I am getting : Too few type arguments to AbstractPresenter(Of TView, TPresenter)
Which I don't understand because this is a valid statement according to question. Also showing valid in other C# to VB.NET converters when converting typeof(AbstractPresenter<>).
The "GetType" method returns a type so why does VS flag the "DirectCast" statement as invalid?
Sub Main()
Dim d As C = New C
d.Value = 5
Dim o As Object = d
[code]....
I'm developing a vb.net program with VS2008. In my case, dt_list is a instance member as List(of Single). When I wrote dt_list = CType(ser2.Deserialize(r), dt_list.GetType()) VS2008 complains about "Type 'dt_list.GetType()' is not defined.".
View 2 RepliesI am trying to get the type of a class by calling Type.GetType(), however it is throwing an null reference exception. I'm supplying the fully qualified name of the class as a string, I'm not sure what I am doing wrong. Here is what I am doing:Type.GetType("The.Name.Space.TheClassName")That is the fully qualified name of the class, it works fine for import statements.
View 2 RepliesDim x = GetType(List(Of )) 'valid statement
Dim list As New List(Of String)
Now I want to see if list is a List(Of T) variable: Dim isList = TypeOf list Is List(Of ) On the last line I get a compile error: "Type Expected". Is there any cheap-performance TypeOf operator alternative for generics?
I'm using DataGrid to populate the list, inside the DataGrid I'm trying to put DropDownList. I have the sample code in C#, then trying to convert to VB. But got error.
See the WORD with BOLD in VB. The error is "Operator '=' is not defined for types 'System.Type' and 'System.Type'."
In C#
-------
string sOid = string.Empty;
Control myCtrl1 = datagridlist.Items[i].Cells[2].FindControl("ddlcountry");
if (myCtrl1 != null)
[Code].....
The code below works for the class that I hard coded "XCCustomers" in my RetrieveIDandName method where I use CType. However, I would like to be able to pass in various classes and property names to get the integer and string LIST returned. For example, in my code below, I would like to also pass in "XCEmployees" to my RetrieveIDandName method. I feel so close... I was hoping someone knew how to use CType where I can pass in the class name as a string variable.
Note, all the other examples I have seen and tried fail because we are using Option Strict On which disallows late binding. That is why I need to use CType.I also studied the "Activator.CreateInstance" code examples to try to get the class reference instance by string name but I was unable to get CType to work with that.When I use obj.GetType.Name or obj.GetType.FullName in place of the "XCCustomers" in CType(obj, XCCustomers)(i)I get the error "Type 'obj.GetType.Name' is not defined" or "Type 'obj.GetType.FullName' is not defined"
'+++++++++++++++++++++++++++++++
Imports DataLaasXC.Business
Imports DataLaasXC.Utilities
[code]....
I'm sure this is straightforward but I cannot find the correct string to get a google result. In VB.NET what is the difference between = (equals sign) and := (colon followed by equals sign)?
View 3 Repliescan anyone tell me book for VB.net for beginner and complee package of books important for VB. as i don't know anything abt VB.
what is difference between VB.net and asp.net and c#??
Possible Duplicate: What are the most important functional differences between C# and VB.NET? What are the basic difference between c# and VB.net?
View 3 Repliesknow the difference between C#.Net and VB.Net. I use C#.Net for my projects, but when ever I met with some other programmers they often called VB.Net more powerful and easy, than C#.Net. I always asked them "Why it is more powerful then C#, since it uses the same framework?" but still I didn't get any answers.
View 3 Replieswhat exactly distinguishes a COM component from a DLL? Isn't a COM component just a library of functions that can be called from another application? Why is using a COM component so much more complicated than just registering it like one would do with a DLL?
View 4 RepliesI'm looking for an explanation of the difference between
Dim sw1 = New StringWriter()
Dim sw2 As New StringWriter()
Both seem to instantiate new string writer instances that I can use.
I was under the assumption that VB's For Each loop was the same as a For Next loop. But when i try running the following code I do not get the expected result.
[Code]...
I have this code, first I thougt it should be the same but i cant acces the info in the same way .. why is this???
Dim tp(,) As Integer = {{1, 3, 5, 9, 7}, {34, 3, 4, 5, 6}}
Dim tpo(1)() As Integer
tpo(0) = New Integer() {1, 3, 5, 9, 7}
[code].....
The first one I use only one for each and the other one I use two .. why is this different? are noy they 2 dimensional arrays ???
What is the difference between VB and VB.NET?
explanation with examples preferred
The next code works fine in C#:
[Code]...
But this code crash with a OverflowException in VB.Net.
[Code]...
Both codes seems the same to me. What is the difference and how can I get the C# code converted to VB.Net?
For those who have experience, working with VB.NET, it's easier to use SlimDX or SDL? The tutorials for SlimDX are already written for .NET, but I've read that SDL it's a lot easier than DirectX itself.in my case, I just need 2D graphics.
View 4 RepliesI have two arraylists, and I would like to have a new arraylist with only the uncommon items. Is this the "best" or at least decent way to do it?
[Code]...
[Code].....
What is the major difference between 'for each' and 'for' loops in .NET? Is there any performance gain while comparing these two? Which one gives a better performance/faster/memory management?
I have in the past used .net executables as libraries. I'd just add them to the references in visual studio and I was ready to go. Today I tried the same to a new exe (actually mine) and it doesn't seem to work. When I add it to Visual Studio and try to watch its members on the Object Browser, it doesn't show up anything inside that executable's assembly.
I know the main difference between an exe and dll is that the first has an entry point while the 2nd doesn't. Are there any more differences? I know that unmanaged dll's also have a DLL entry point, do .net have one too?Also, what might be the reasons that could make my standard exe/dll (with this i mean, not obfuscated or anything extreme like that) not show up anything in the Object Browser?