.net - Test If Property Of Type System.Collections.Generic.List(of T)?
Apr 10, 2012
I need to be able to tell if a property is of type List(of T)but am currently unable to. if i do
TypeOf (UpdateTo.GetType.GetProperty(node.Name)) Is System.Collections.Generic.List(Of Object)
I get the following error
TypeOf (UpdateTo.GetType.GetProperty(node.Name)) Is
System.Collections.Generic.List(Of Object) Expression of type
'System.Reflection.PropertyInfo' can never be of type[code]......
View 1 Replies
ADVERTISEMENT
Sep 21, 2011
I'm having a problem with this code in the highlighted line(*); getting the error in the heading.
Dim htmlarraylist As New List(Of iTextSharp.text.IElement)
htmlarraylist = *HTMLWorker.ParseToList(New StreamReader(tempFile), New StyleSheet())*
[Code].....
View 2 Replies
May 14, 2012
I'm getting an error after sending a list to a web service.This is the code that is calling the web service:
Dim sProgramInterest As New List(Of Integer)
crmService.InsertProspectGetId(sProgramInterest.ToList)
But I'm getting this error.
[code].....
View 3 Replies
Feb 5, 2011
[code]...
What's really the point in using the former?It's hard to use linq if I used the former. I have to convert that to an array first which is difficult because there is no (asarray) function.I think I would change all of my code that's using System.
Collections.Specialized.StringCollection to System.Collections.Generic.List(Of String)
View 2 Replies
Mar 12, 2009
I have converted c# .cs to vb:= I have 6 errors on:
Red "List" says Too few type arguments to system.Collections.Generic.List(Of T)'
Orange "Calendar" says Value of type 'System.Windows.Forms.Control.ControlCollection' cannot be converted to 'Form1.Kobush.Windows.Forms.Appointment'.
[code]....
View 6 Replies
Jan 27, 2010
imagine i want to add an extension method to System.Collections.Generic.List(Of T)
let's say i want to give it .GetUBound which returns Count-1
View 7 Replies
Feb 2, 2012
I have a lists of different custom classes and each must be sorted severals times before the algorithm is complete. For each sort I wrote a comparer. Sofar so good. Everything works. But: By now I have abou a dozen different comparers in more than one class and it is still getting more. I wonder if there is a way to limit the number by writing a new general function that can be used to sort all lists without the need for a specific comparer.Below is what I've got so far. But it does not work.
"System.Collections.Generic.List(Of ClassA)" can not be converted into "System.Collections.Generic.List(Of Object)."
[code].....
View 2 Replies
May 3, 2012
i have issue returning a list in a web method. here is the code
<WebMethod()> _
Public Function getTags(para_parents As String) As List(Of getTypeDetailsByParentName_Result)()
Dim context As New PPEntities
[code]....
the error is
Value of type 'System.Collections.Generic.List(Of SaftyonRoad.getTypeDetailsByParentName_Result)' cannot be converted to '1-dimensional array of System.Collections.Generic.List(Of SaftyonRoad.getTypeDetailsByParentName_Result)'
View 1 Replies
Jun 10, 2012
I am trying to pass a System.Collections.Generic.List to another class. The collection is created in class2 and then passed into class1
[code]...
However I get a 'Null Reference Exception error' when I run the program. It seems f_str in the line 'For Each s As String In f_str' is null.
View 3 Replies
Feb 15, 2009
how to find a value in the System.Collections.Generic.List.I have:
Private ids As New List(Of Byte())
ids.add(New Byte(){&HA8,&H0F})
ids.add(New Byte(){&HFF,&H03})
ids.add(New Byte(){&H10,&H00})
I would like to find for example: &H10,&H00 in that list and if there isn't the stuff I wan't to find then how do I know that?
View 3 Replies
May 20, 2011
in what situation will an item in System.Collections.Generic.List not be removed successfully?url...The way they phrase it makes me think that it is possible that a Remove operation on an item found in the List(Of T) could actually fail.
View 4 Replies
Mar 20, 2009
I need another (dozen) pair of eyes on this. The following code:
Interface iRuleEntity
Function GetRuleViolations() As List(Of RuleViolation)
End Interface
Partial Public Class Feedback
[code]....
is giving me this error:'Feedback' must implement 'Function GetRuleViolations() As System.Collections.Generic.List(Of RuleViolation)' for interface 'iRuleEntity'.
View 2 Replies
Jan 7, 2012
And here is the code that produces the error
CODE:
How can i cast this one?
View 1 Replies
Feb 12, 2011
This code:
vb Dim s As String = strContents '<a global variable) Dim currentPos As Int64 = 0 Dim endPos As Int64 = strContents.Length - 1 '// A dictionary, used to count the frequencies Dim characterCounter As New Dictionary(Of [String], Int64)() While currentPos <> endPos '//
[CODE]...
Gives this error: Value of type 'System.Collections.Generic.KeyValuePair(Of String, Long)' cannot be converted to 'System.Collections.DictionaryEntry'.
View 2 Replies
Jul 7, 2010
I have created a Dictionary class (MyDictionary for the example). I am currently trying to pass MyDictionary into a function, filter it into a new instance of MyDictionary and pass this new instance into another method. When I am attempting to create the second instance from the filtered first instance of MyDictionary via Lambda Expressions and the ToDictionary Method, I am getting the following error:
Unable to cast object of type 'System.Collections.Generic.Dictionary`2[System.Int32,System.String]' to type 'MyDictionary'. I have simplified the example and recreated it in LINQPad and am getting the same error.
Here's the simplified version of my code:
[Code]...
View 2 Replies
Jan 3, 2012
given the following class structures:[code]I add the following property to MyList, trying to answer questions like "find out the number of elements with specified type, say Derived1, inside MyList?"[code]
View 1 Replies
May 20, 2011
If i wish to put items into a System.Collections.Generic.Dictionary, I can either Add or set the Item.I know if you do Add it helps you check if the key already exists and if not it throws an exception.Now I'm curious, so if I'm adding a ton of items, should I prefer setting Item instead of Add since Add does unnecessary checks that may actually slow things down?
View 3 Replies
Sep 21, 2011
I am planning to use a List in my application but when I was searching for System.Collections.Generic, it only has System.Collections. I tried to look it up in the "add reference" and its not there.
View 2 Replies
Dec 22, 2010
I have a series of API calls that are returning J# data types. I have been able to convert most of the data types (Integer, Boolean, Double, Float, etc) just fine.What I need to do now is convert a java.Util.Collection to a VB .NET collection (ArrayList)
Here is my attempt:
Public Function MakeDotNETCollection(ByVal javaCol As java.util.Collection) As Collection
Dim dotNetCol As Collection
[code]....
I keep getting a runtime error "Unable to cast object of type 'AbstractListlistIterator' to type 'System.Collections.IEnumerator.
View 1 Replies
Jun 30, 2011
I am trying to create a list of a generic type in vb.net 2.0 framework.
This is the generic type definition:
Public Class GenericParamMap(Of T)
Public Sub New(ByVal pParamName As String, ByVal pPropValue As T)
mParamName = pParamName
[Code]....
The compiler does not allow a "T" in the method's parameter because it's not defined, but I'm not sure how or where to define it. I thought it was okay to have a generic method definition.
View 2 Replies
Dec 16, 2009
We have migrated our Vb6 application to VB.NET using a third party tool. Now we are in a process of Refactoring and introducing object oriented concepts in the application.
In VB6, we were using structures in many places. As a part of introducing object oriented programming,
1. is it a good idea of changing all Structures to Classes? or Is there a concept of "Generic Structure" similar to Generic collections, Generic classes?
2. Can some one guide me any source containing guide lines or best practices for applications that are migrated to VB.NET from VB6 and implementing object oriented programmaing.
View 3 Replies
Jan 10, 2012
Firstly, i have a grdData at my main page. After choosing the data i want and went to another page using
[Code]...
View 1 Replies
Oct 1, 2009
I'm looping all the properties in an object via reflection:
For Each p As PropertyInfo In values.[GetType]().GetProperties()
If p.CanRead Then
'Do stuff
End If
Next
how to determine whether the property in question is a generic List(Of T)? If it is I need to loop the list itself.
I've experimented with GetType and TypeOf but have not managed to get anything working.
To clarify, I want to keep this generic. I do not want to specify the type of T, I need to loop the list items and call the ToString method on each item. T could be one of a number of different types (application specific reference types). Is it possible to do this without specifying types?
(VB.NET 2005 with .Net 2.0)
View 3 Replies
Mar 12, 2010
I have a function to create a pdf which should return bitarray. Below is the code
Public Function GenPDF() As BitArray
Dim pdfdoc1 As BitArray
Dim doc As New Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35)
[code]....
View 1 Replies
Sep 12, 2011
I have a question about ASP.Net, visual basic I have 2 LINQ query's, the first one works, the second one doesnt, produces a
"Unable to cast object of type 'System.Data.Objects.ObjectQuery'1[SelmaV2.Products]' to type 'System.Collections.Generic.List'1[System.String]'.
[Code]....
View 1 Replies
Mar 23, 2011
Public Class notifierMain
Public Class Contacts
Inherits List(Of row)
Public Sub New()
[code]....
When I debug this winforms application I get curType = "notifier.notifierMain+Contacts+row" I want to the Validate function to know it is in MyContacts. How do I do this?
View 3 Replies
May 26, 2010
I want to create a generic list - but I want to specify the type at runtime - is there a way I can do this? using reflection perhaps?Something like this...
Public Shared Sub create(ByVal t As Type)
Dim myList As New Generic.List(Of t)
End Sub
View 2 Replies
Feb 21, 2011
Anyone know a good workaround for the lack of an enum generic constraint?[cod]e...
Is is possible to limit the generic type parameter [I don't know if that's the right name] to an Enum?[code]...
View 4 Replies
Nov 23, 2011
I'm trying to use a generic list without knowing the type when loading the page. I have a typePropertyCollection which inherits from List(Of PropertyData). The usercontrol that uses this collection doesn't know what type of data is used (which objects). So when the page is loaded, I pass along the type to the usercontrol using a dependencyproperty. This type ends up in this method:
Private Shared Sub OnObjectTypeChanged(ByVal obj As DependencyObject, ByVal args As DependencyPropertyChangedEventArgs)
Dim objectType As Type = TryCast(args.NewValue, Type)
[code].....
View 1 Replies
Jan 13, 2011
I would like to write a generic function that would search a List(Of T) for all elements of type TFilter and return a List(Of TFilter) which comprises those elements.
I've tried this:
Public Function FilterList(Of T, TFilter)(ByVal ListToFilter As List(Of T)) As List(Of TFilter)
Return ListToFilter.FindAll(Function(z) z.GetType.Equals(GetType(TFilter))).ConvertAll(New Converter(Of T, TFilter)(Function(z) CType(z, TFilter)))
End Function
But, it gives the following error:
Value of type 'T' cannot be converted to 'TFilter'.
View 2 Replies