Generic List - How To Get Data From TXT File

Jan 4, 2012

I'm looking for a method for reading data from a txt file. The text file have this kind of structure (fixed length fields):
0000 AAAAAA BBBBBB CCCCCCCC
0000 JJJJJJ III RRRRRR
1111 XXXX YYYYYYYY ZZZZZZZZ
1111 WW PPPPPPPP ZZZZZZZZ
1111 XXXX YYYYYYYY ZZZZZZZZ
2222 XXXX YYYYYYYY ZZZZZZZZ
...

I have to get them in groups by first field, in some kind of list of dictionary lists or something like this. For this particular example the solution would be:
id(list): 0000,1111,2222.....
(content)List: 0000
field1(list): AAAAAA,JJJJJJ
field2(list): BBBBBB,III
field3(list): CCCCCCCC,RRRRRR
(content)List: 1111
field1(list): XXXX,WW,XXXX
field2(list): YYYYYYYY,PPPPPPPP,YYYYYYYY
field3(list): ZZZZZZZZ,ZZZZZZZZ,ZZZZZZZZ
(content)List: 2222
field1(list): XXXX...
field2(list): YYYYYYYY...
field3(list): ZZZZZZZZ...

Right now I have the the whole text stored in a list of strings (one per line).

View 2 Replies


ADVERTISEMENT

Bind Generic List Data To Combobox?

Jan 21, 2011

Please forgive, I'm new to Silverlight and am still trying to wrap my head around data binding...

I have a generic list obtained from a class using LINQ. The list has 4 objects, each object consisting of a Letter property (string - A, B, C and D) and a corresponding Number property (integer - 1, 2, 3, and 4).

In Silverlight, I have a combobox control and a text block. I'm trying to figure out how to:

Bind the combobox to the generic list so that the letters populate the combobox.When the user selects a letter in the combobox (say C), the corresponding integer value (3 for this example) is displayed in the text block.

View 2 Replies

.net - Creating A Generic List Of A Generic Type

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

Determine If Property Is Generic List<of T> Via Reflection And Loop List Items

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

Get Type Of Derived Generic List Class From List Item Method?

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

.net - Returning A List Using Entity Framework, 'System.Collections.Generic.List Cannot Be Converted To '1-dimensional Array

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

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

.net - Sort Generic List Based Upon A Different List?

Oct 29, 2010

What would be the fastest way to sort a list that contains a list of objects, based upon another list? An example follows:Say I have multiple lists of employees. Each individual list has a common property value, say "Department". So I have a list of employees, in one list they all have the department string value of "Sales". In another list all the objects have a department value of "Finance". These lists of employees are then contained in a list which holds them all.

I have a second list, which should drives the sort order of the employee lists. The second list simply contains a list of strings like, "Finance", "Sales", "IT" and so on. I'd like my lists of customers to be sorted in the order of "Finance", "Sales", etc.I'm using VB.NET in .NET 2.0

View 1 Replies

Generic TypeOf Operator - See If List Is A List(Of T) Variable - Error: "Type Expected"?

Jan 5, 2011

Dim 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?

View 2 Replies

Error - Red "List" Says Too Few Type Arguments To System.Collections.Generic.List(Of T)'

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

Use Data From A .txt File To List The Grades In A List Box?

Dec 3, 2009

I'm an instructor trying to use data from a .txt file to list the grades in a list box. I just want to grab the data from a .txt file, list the total amount of grades in a list box, the mean (avg) and the standard deviation.

View 5 Replies

Generic Class Array - Reading In A Excel File And Extract Data To Store In A Array

Sep 9, 2010

I want to reading in a excel file and extract the sCodenumber sDescription ans the sStatus and store them in a array : StatusComposeArray(5200) As MyCompose. After this I need this array for comparing outside this class. But as can you see the array is defined inside the sub: ReadingIn_ExcelFilesCompose [Code]

View 2 Replies

Asp.net - Find The Max Id From A Generic List?

Oct 13, 2011

i m getting a collection of data in list's object. And from this list i want to get the maximum id.`

Dim objinfo As List(Of AlbumInfo) = objPhotos.GetPhotos_Alb_ID(Me.ModuleId, hdd_AlbID.Value)
Dim Photo_Image As String = ""
Dim str As String = Photo_Image & fu_Photo.PostedFile.FileName.Substrng(fu_Photo.PostedFile.FileName.LastIndexOf("."))

[code]....

this returns the "0"th positions id from Convert.ToString(objinfo.Item("0").Photo_Id + 1)but i want to get the last item's id.

View 17 Replies

C# - Sum Of A Column Of Generic List?

Jan 5, 2011

i have list of string like this :

Dim totalPrice As New List(Of Integer)

how can i get sum of column(0) (C# or VB) ?

View 4 Replies

Generic List, Add, And Same Values?

Jan 17, 2011

<div class=PhorumReadBodyText>Hi, I have a problem with adding of items to generic list, problem is when I insert 1. item to the list, everithing is ok, but if I insert second item, first and second has same values.

code looks like that (asp.net 4.0): </div> <div class=PhorumReadBodyText> </div> <div class=PhorumReadBodyText>Partial Class _Default
Inherits System.Web.UI.Page

[Code]...

View 1 Replies

How To Add Items To Generic List

Jan 17, 2011

I have a problem with adding items to generic list, problem is when I add 1. item to the list, everything is ok, but when I add second, first and second has the same values...

This is code (asp.net 4.0):
Partial Class _Default
Inherits System.Web.UI.Page
<Serializable()>
Public Class Product
Shared Property Material As String
[URL]

View 7 Replies

Loop Through Generic List

Aug 26, 2009

In my VB.net application I am populating my customer object and looping through it as shown below.As there are thousands of customers, I want to do it 500 customers at a time.Is there anyway I can have one more For loop to process 500 customers at one shot in vB.netI am not using LinQ as the database is Oracle.[code]

View 2 Replies

Looping Through Generic List?

Apr 30, 2010

I want my loop to loop until it reaches the last string in my generic list. I know I could simply insert the last index of the list as an integer but I want to be able to use this if my list grows too. How could I achieve this?

View 5 Replies

Searching A Generic List

May 14, 2009

I have been reading extensively about searching generic lists in VB.NET with the usage of delegates.However, I still cannot seem to grasp how to achieve what I want to, which I believe is frustratingly simple! I have a list populated with instances of an object with three parameters (fields/ variables).When I receive a new object to add to the list I want to search the list for the "layer" field.If the field matches then I will replace that row (object) in the list with the new object, if no match is found then I will add it to the list. [code]

View 3 Replies

Splitting A Generic List?

Jun 11, 2011

i have a generic list of type datarow.i have to split this list at an index and then use both parts of the list.

View 2 Replies

.net - GroupBy 2 Values In A Generic List?

Aug 18, 2010

I'm using VB.NET on Framework 2.0. I'm looking to quickly group a Generic List<> by two properties. For the sake of this example lets say I have a List of an Order type with properties of CustomerId, ProductId, and ProductCount. How would I get the average of ProductCounts grouped by CustomerId and ProductId in VB.NET ?Unfortunatly I cannot do this at DB level (which would have been easy). Also I cannot use LINQ or Lambada as Im on Framewwork 2.0. So I need to do this at application level in VB.net. The list is returned to me sorted by CustomerId and ProductId so I guess with a few loop sI should be able to create a average value for but there must be a cleaner way to do this?

View 1 Replies

.net - Iterating Through Generic List Of String?

Jan 28, 2012

I have the follow code in my program where I hit a SQLCe database to append the results into a list. That part works, but instead of exiting the function 'QueryDB' it goes to the else statement and runs the function again, which will return a null value. I designed it this way becuase I wanted to check to make sure the database is open before I try to execute the SQL statement, and if it's not open, call the method to open it and run through the function again.

[Code]...

View 1 Replies

.net - Sort Generic List On Two Or More Values?

May 15, 2009

We have a generic List(Of Product) that must be sorted on two or more properties of the Product class.

The product class has the properties "Popular" numeric (asc), "Clicked" numeric (desc), "Name" string (asc). In order of naming the properties we want the list to sort.

How can it be sort with an lamba statement? If have found to sort the list based on one property.

View 4 Replies

Add Custom Class To A Generic List?

May 10, 2010

I created two classes. One class is StudentClass and the other is HomeroomClass. The HomeroomClass contains a readonly property as a generic list of the StudentClass. [code]...

View 6 Replies

Asp.net - Linq To Sql Convert To Generic List In .NET?

Jul 2, 2009

I am trying to learn some VB.NET for my coo-op that starts next week, and for that reason i took my portfolio web site that is on C# and just started to converting it to VB.NET to get familiar with the syntax.

I am sure my problem is simple however i have a hard time solving it. I am trying to grab data with the linq query and then return it as list to bind to the Repeater.I have the following function:

[Code]...

And it would work fine. However if I try to use ToList() in VB.NET i am getting error that it cannot convert it from ling to sql List to the generic list. How do i do this convertion in VB.NET ? or maybe there is another way ?

I am decent when it comes to C# however somewhat lost with the VB.NET syntax.

View 1 Replies

Better Way Of Filling A Generic List From A SQL DataAdapter?

Apr 11, 2009

I have an existing application that uses Active Record for its data retrieval. It's in VB.NET (first time I'm doing VB.NET; I usually work in C#). And I'm building a method to return a List(Of T) of an object. The current pattern uses a SQLDataAdapter to populate a datatable. I COULD add the record to the List(Of T) as I fill the datatable, but there HAS to be a better way to do this.

View 1 Replies

C# - Get Values From An Enum Into A Generic List?

Nov 21, 2011

I don't know how to convert the following line from VB to C#:

Dim values As New List(Of T)(System.Enum.GetValues(GetType(T)))

My version doesn't work:

List<T> values = new List<T>(System.Enum.GetValues(typeof(T)));

The best overloaded method match for 'System.Collections.Generic.List.List(System.Collections.Generic.IEnumerable)'
has some invalid arguments

The constructor-parameter doesn't take it that way - what cast (or else) am I missing?

For clarification: It is wrapped up within the following generic method

public static void BindToEnum<T>()
{
List<T> values = new List<T>(System.Enum.GetValues(typeof(T)));
//...
}

View 2 Replies

Conversion Of An Array To Generic.list?

Nov 2, 2005

We are currently converting a larger legacy application from .Net1.1 to .Net2.0, both VB. Our new standard is Generic List, instead of arrays.We are recoding component by component. And while not everything is yet stored in generic.list we end up with compile time errors.Converting from generic.list to array is supported with myGenList.ToArray().But from array to generic list isnt that easy."Value of type '1-dimensional array of something' cannot be convertet to 'System.Collection.Generic.List(of something)"I know for sertain that the array consist of the type 'something', so an runtime exception converting is ok.Is there a good way to do the workaround untill the hole application is recoded?

View 1 Replies

Convert DataSet To Generic List?

Mar 11, 2012

How do you convert a DataSet to generic list.I see that in C# you can use .toList(). I'm using .net3.5 vs2008 vb?

View 5 Replies

Creating A Generic List Of A Specified Type?

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







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