Possible To Use Generics To Populate List With Custom Classes?

Jul 10, 2009

I have several different lists I want to call. They all have the same format for the class:
id, value, description, order.
Instead of creating a bunch a classes to return the all of the many lists, I wanted to use generics and just tell it what kind of list to return. However, I can not figure out how to populate the classes.

Here are 2 examples of function in my calling code. This should indicate the type of list and the stored proc used to get the data:
Public Function getTheEyeColors()
Dim glEyeColors As New GenericList
Return glEyeColors.GetALList(Of EyeColor)("GetAllEyeColors")
End Function
[Code] .....

View 4 Replies


ADVERTISEMENT

[2008] Properties/classes And Generics?

Jan 9, 2009

what I would like to do is create a class that has a few private properties and one public property.the end result of the class is to return a list(of servers)below is what I am thinking. My brain just can't come up with the correct answer.

namespace sample
Private _servername As String
Private _farmname As String

[code].....

View 1 Replies

Have A List Box With A Custom Data Template Populate With User Data?

Jul 2, 2011

I am working on a project and I want to have a list box with a custom data template populate with user data. My question is, when I click on an item in the list box, how can I tell what item I selected? Basically, if I select "kevin", I want to display his data. If I select Dave, I want to display his data. I do not know how to get the data our after it is bound...

View 4 Replies

XML To LINQ - Get List Of All Products From XML Doc And Put Them Into A Generics List

Jun 30, 2009

I'm basically brand new to LINQ. I've seen some examples that allow me to strong type objects using LINQ but I don't really understand them because they're in C#, which I guess lets you do different things with LINQ(I think?). [Code] I just want to get a list of all the products from the XML doc and put them into a Generics list.

View 3 Replies

Difference Between Array List And Generics

Dec 20, 2010

I know boxing and unboxing part in arraylist but question is if I define only string in arraylist then there is no question of boxing or unboxing. What will be the difference.

View 1 Replies

Free Items In Generics List?

Mar 21, 2011

I have been trying to use the Generics List as a means of storing a large amount of data that I am reading in from hardware. I defined a class called 'Datapoint', that has several public variables of type Double, and as I read in a number of points (this is of variable length, and could potentially be very large), for every point I create a new instance of 'Datapoint', update its fields and then add it to a List(of Datapoint) which I named 'Datalist'. All works fine, except when I come to reset the List, I do not know how to free up the allocated memory. I have attached some snippets of code,

[Code]...

View 3 Replies

Generics - How To Limit Size Of List

Mar 24, 2009

I am trying to limit the size of my generic list so that after it contains a certain amount of values it wont add any more. I am trying to do this using the Capacity property of the List object but this does not seem to work.
Dim slotDates As New List(Of Date)
slotDates.Capacity = 7
How would people advice limiting the size of a list? I am trying to avoid doing a statement to check the size after an object is added.

View 5 Replies

Generics - List(Of T) - Use It To Hold Items Of Several Types?

Oct 3, 2009

Assuming a base type of "Message"...

[Code]...

I would like to have one collection of Message objects which can be either PhoneMessages or MailMessages, so that I can iterate through the list and deal with each message based on what type it happens to be.

Attempting just to use .Add() fails, saying that I can't add an item of type PhoneMessage to a List(Of Message). Is there some elegant way to accomplish what I'm trying to do? I had thought I could accomplish this with generics, but I think there's a gap in my understanding. If it can be accomplished in .NET 2.0, that would be ideal.

View 4 Replies

Difference Between C# And Custom Classes

Sep 1, 2011

I have been out of VB.Net way too long, I have a custom class in C# that needs to be converted to VB.Net and would like to know the main differences between them. Certain things in C# I cannot seem to do in Vb.Net with classes such as use: public classname or public [classname](DataTable dt) in VB.net

M[Code]...

View 3 Replies

Working With Custom Classes?

Dec 16, 2010

I already know how to make really basic custom controls where I can pass in new variables to treenodes because of my custom class, but it's not really working out well for me.I figured out how to read the new values & change them while their in the normal treenode because oddly enough once i've passed in an object from my custom treenode class it worked but I want to know a few things.

1.With my custom class, I can't do things like the following.

MsgBox(
New
TreeNode("Today").IsSelected)

If I replace with CustomTreeNode it doesn't work no matter what I do even working with sub/new it always shows a default value instead of what value is, the most I can think of is because sub isn't returning value, but you can't return value in subs, how are you meant to make lines like that work?

2.Also anyways just for sake of having good intellisense & workings is there a way I can make a class of CustomTreeView that's using my CustomTreeNode's so that I can work on things by code in the EXACT same manor I used to given the name is the same but have my new custom values?Currently im stuck passing any changes using the new type & taking it out I type cast over to the custom type again so i can read the values, but I just want was wondering what I need to do to make it work like a real control would.

Anyways is there any way to over-ride the default control or something instead so I can simply add the new variables in there? I want the same functionality of the normal control just with the added variables so I can work with data pertaining to the nodes of each item in the treenode easier.I already used the Tag value to store some information but it's not like that there are 100 different variables to store information & it's not like anyone wants to store lots of values in 1 variable & parse out the one you need, it's possible but if I can create something good here, I want to use whatever I can make instead of taking my time on working on a more painfully difficult to work with, at least later when I might even need even more variables stored pertaining to each of the items.

View 7 Replies

Converting Types Using Custom Classes?

Sep 16, 2009

I'm studying for the MCTS exam 70-536 and have come across the following question:Given the following Visual Basic code sample, which interface must the custom class MyClass implement?

Dim a As MyClass, b As Boolean
a = 42
' Convert using ToBoolean.
b = Convert.ToBoolean(a)
Console.WriteLine("a = {0}, b = {1}", a.ToString, b.ToString)

Before even looking at the possible answers, I can't get past WHY on earth would we be converting the number 42 to a Boolean value?? I tried this and as I suspected it did NOT compile! Is this a trick question or am I missing something? I realized that in order for the code to work, I would need to implement one of the interfaces shown in the multiple choices. STILL, would there EVER be a purpose for this particular conversion?

View 4 Replies

Custom Controls - .net Inherits 2 Classes?

Jan 16, 2012

inherit from two classes in VB.net?We are developing Custom User Controls that inherits from say System.Web.UI.WebControls.Label. We are planning on implementing a bunch of these controls but they will share mostly the same additional properties. We are hopeful about centralising these properties.I have looked into interfaces but it seems they only 'contract' properties you need to implement.

View 2 Replies

Looping Through Custom Collection Classes

Oct 5, 2011

I have a custom collection class. The main member of the class is a List(Of T). I did what this article says: [URl] For some reason though I can only foreach my collection once. The second time it tries it goes out of range because the position does not reset after the first foreach. What am I doing wrong?

[Code]...

View 4 Replies

.net - Arraylist Of Custom Classes Inside My.Settings?

Oct 17, 2010

I have a Visual Basic .Net 2.0 program. I'm moving the settings from an older settings file, to an app.config program settings file. I'm trying to do this as nicely as possible.

So, I added my setting as shown in this image.

On load I do this:

If My.Settings.databaseConnectionSettings Is Nothing Then
My.Settings.databaseConnectionSettings = New ArrayList()
End If

[Code]....

So, the question is, how do I get that arraylist of my DatabaseConnectionSettings saved to persistent storage? I want to do this in the cleanest way possible. That is, I don't want to have to convert it to a string or save it to a separate file every-time I want to use it. I would like to be able to use the My.Settings accessor method.

View 1 Replies

DataGrid To Display Custom Classes Via A BindingSource

Jul 9, 2011

I'm using a DataGrid to display the below custom classes via a BindingSource, I'm trying to figure out a way to save them to a file either by serialization or by some other method. I've tried a lot, but I think it has a hard time serializing because the Account object has the CharacterList object or something. [code]

View 3 Replies

Add Classes And Custom Form With Code In A Setup Project?

Jul 22, 2010

I have a main application and the setup project for the app in a single solution.I have custom classes to detect in sql server 2005 express is installed. if it is not I have classes to install it and create my database.Now I need to call the above classes from my setup project before it installs my actual application on a client pc.

View 2 Replies

Winforms Data Binding: Custom Classes Or Datatable?

Jul 8, 2009

Am in the process of architecting a new windows forms application, and I intend to use Visual Basic 2008 and SQL Server Express 2005. This is my first application in .Net and I really want to observe the best OOD & OOP principles to create an application that is easy to maintain and extend (add new functionality). My issue is in regard to databinding on the UI. From experience, what do you guys recommend to use for databinding? Should I return datasets/datatables from my Business Layer and bind these to UI controls or should I return Business Objects and bind these to UI controls? And what are the pros and cons of each approach?

View 1 Replies

Throw System.Exceptions From Within Custom Classes To Calling Code

Jul 9, 2010

I Have just been watching a video on throwing Exceptions. Are you supposed to throw System.Exceptions from within your custom classes. to the calling code, Which other way can they communicate. I have read in several places it is bad practice to throw SystemExeptions.

View 3 Replies

VS 2005 - How To Make Custom Base Classes Available To Future Programs

Oct 22, 2010

I have written multiple programs in the past that deal with cad data. Points, lines, arcs, etc. For each program I ended up creating slightly different versions of some really base classes like a class that defines a point:

<Serializable()> Public Class Point
Public x As Double = 0
Public y As Double = 0
Public z As Double = 0
End Class

My question is how would I use that class in such a way that it could be in a namespace and imported into any future project that I write?

View 2 Replies

Pass Generic List To A Function That Has A Custom Defined List

Apr 7, 2011

it seems always at this time I cant figure out how to do something maybe it has something to do with lunchtime.

Im having trouble using a method that is defined by an outside company

This is a link to their integration guide:

[URL]

This is their documentation for the class Im trying to use

OrderQueryWebService Class

This class is for SID in particular and is made for use with the notification methods. This is for the Order Query Web Service specifically, allowing clients to return the status of transactions for their merchant, whenever they want to.

Methods
/ <summary>
/ Pass through the variables required and receive a list of Transaction
objects showing transaction status

[Code].....

The MerchantCode, the MerchantUsername, the MerchantPassword are all good the List is a custom type called SetComHash.Transaction

Everytime I try adding a string to the list such as the transactionNumber and some other values it gives me a type error:

"Value of type string cannot be converted to 'SetcomHash.Transaction'

View 13 Replies

Compare Long List Of Classes?

Jun 23, 2011

I have 2 lists of classes with thousands of elements. Each class has the same structure.

I need to synchronize the 2 lists by comparing the version, the dateandtime and if they have been labelled to be deleted in one list.

is there any trick to make this very long process as fast as possible apart from splitting the work on threads?

View 8 Replies

Create A List Of Mulitple Classes?

Nov 5, 2011

I am working on an assignment that requires several classes, two of which inherit a base class.[code]...

Is it possible to create a list that would contain both the Checking balance and the Savings balance since they are separate classes?

View 10 Replies

How To Correctly Initialize A List Of Classes

Jun 27, 2011

I'm trying to create a group of engineers (a class) at a specific location (also a class) -- my code is bombing with a NullReferenceException at _engineers.Add(e), and I'm not sure why.[code]

View 3 Replies

List Of Pcap.Net Members Or Classes?

Jun 20, 2012

Need a list of Pcap.Net members or classes? Their website doesn't have much documentation and have looked around in the forums.

I have found..
PacketTs = Packet.Timestamp.ToString("yyyy-MM-dd hh:mm:ss.fff")
PacketS = Packet.Ethernet.IpV4.Source
PacketSp = Packet.Ethernet.IpV4.Transport.SourcePort
PacketD = Packet.Ethernet.IpV4.Destination

[Code]...

View 1 Replies

Passing Values From A List In Classes?

May 5, 2011

Im having a hard time trying to pass the values from a list inside of a class. Im trying to display multiple lines of values from a list inside of a class. My "client" class stores multiple lines of values into a list(of class transaction), with the number value(num) counting each transaction that it adds to the list.

Code:
Public Class Client
Private m_tranlist As New List(Of transaction)[code]....

im trying to display each line that is stored in the list in a label, and im having major trouble. I know all of the results are added into the lists, but how do i call the list in my main form in order to display each line of all of the values? Would I have to look up an index or something?

View 1 Replies

Populate A List(Of Object) In A Class Method, Where The List Was Passed To The Method As A Parameter

Aug 13, 2011

I'm trying to code a class of RandomNumber. One of the class methods needs to populate a "List (Of RandomNumber)" ... which was passed as a parameter to the method ... with 10 random numbers between 1 and 50. DEAD SIMPLE :)

View 6 Replies

VS 2010 Custom Type Array / List With Adding Items And Specifying Custom Type Variable

Jun 21, 2011

I recently downloaded VB 2010 Express so i am quite new to the language, but i have worked with dark basic, which seems to b very similar.Anyway, my problem is that i cannot seem to correctly set out my array of a custom type/class. i am trying to create two arrays, one of available entities and another of selected entities of which the user selects the entities to be dealt with in irrelevant ways. i have creates a button (called test) which adds some entities to the available list and all the entities come back the same value but they shouldnt be as you'll c in the code. i have run the step into command a found that "available.item(#).Name = " will change all of the entity's names.As of current i am working with lists as the array kept asking for a 'new' statement but i couldnt figure out where to put it.[code]

View 7 Replies

Vb.net - Convert From Custom List To List Of String

Mar 25, 2010

I have the following code:

[code]...

The intention is to convert an IList of custom objects to a string equivalent comprising each element in the Ilist. Unfortunately I can't seem to find a way to get the underlying data of the custom object, and of course as in the above example, using object simply gives me a string of types definitions, rather than access to the underlying data.

View 2 Replies

Deep Copy Generic List Of Classes

Aug 15, 2006

If I have a generic.list(of ClassA), is there a simple way to create a deep copy of this list that will not affect the original copy? It seems to work if I have a generic list of Structures, but for some reason the copy constructor for lists of classes only copies pointers to the elements (or maybe a pointer to the whole list?). I would move to structures if it were not for the fact that I can't find a way to edit the members in the structs in the list. eg:list(0).a = 5 'Does not workIs there some way to get around this without declaring an instance of that structure, like this:dim str as StructA = list(0)str.a = 5I'd

View 2 Replies

List Obsolete Classes / Methods In Msbuild

Jun 28, 2010

I have upgraded a visual basic 2005 project to visual basic 2010 (.net framework 4.0). I want to list all obsolete functions used in this project in order to change it with newer ones. How can I treat obsolete functions warnings as errors in visual basic 2010 ms-build?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved