Click here to Skip to main content
15,886,083 members
Home / Discussions / C#
   

C#

 
Generalproblems rightformating [modified] Pin
stephan_0078-Apr-08 6:24
stephan_0078-Apr-08 6:24 
GeneralRe: problems rightformating Pin
Luc Pattyn8-Apr-08 6:42
sitebuilderLuc Pattyn8-Apr-08 6:42 
GeneralRe: problems rightformating Pin
stephan_0078-Apr-08 10:03
stephan_0078-Apr-08 10:03 
GeneralChecking integer values and adding same types together Pin
Sharkadder8-Apr-08 6:23
Sharkadder8-Apr-08 6:23 
GeneralRe: Checking integer values and adding same types together Pin
carbon_golem8-Apr-08 7:25
carbon_golem8-Apr-08 7:25 
GeneralRe: Checking integer values and adding same types together Pin
Sharkadder8-Apr-08 7:50
Sharkadder8-Apr-08 7:50 
GeneralRe: Checking integer values and adding same types together Pin
carbon_golem8-Apr-08 16:37
carbon_golem8-Apr-08 16:37 
GeneralRe: Checking integer values and adding same types together Pin
Dave Kreskowiak8-Apr-08 7:55
mveDave Kreskowiak8-Apr-08 7:55 
If I understand your request, you're looking to count the number of occurances of each 1, 5, 10, 100, and so on, on each line or file?

Easy. Use a Dictionary, or some other Key/Value pair collection to track each item and the count for it. Off the top of my head, the core of something like this would look similar to this:
Dim itemCounts As Dictionary(Of String, Integer)

'open file and read a line here...
Dim values() As String = lineRead.Split(New Char() {","c})
For Each value As String In values
    If itemCounts.ContainsKey(value) Then
        ' If the key is already in the collection, up the count by 1.
        itemCounts(value) += 1
    Else
        ' If the key doesn't exist yet, add the key with the count of 1.
        itemCounts.Add(value, 1)
    End If
Next
...
Return itemCounts

You'd treat each value as a key to the collection, whereupon each value associated with the key would be the count of the occurances of those keys.


A guide to posting questions on CodeProject[^]



Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007, 2008




GeneralRe: Checking integer values and adding same types together [modified] Pin
Sharkadder8-Apr-08 10:53
Sharkadder8-Apr-08 10:53 
General(De)serialization progress Pin
Stevo Z8-Apr-08 6:21
Stevo Z8-Apr-08 6:21 
GeneralRe: (De)serialization progress Pin
Giorgi Dalakishvili8-Apr-08 6:45
mentorGiorgi Dalakishvili8-Apr-08 6:45 
GeneralRe: (De)serialization progress Pin
Stevo Z8-Apr-08 6:58
Stevo Z8-Apr-08 6:58 
GeneralRe: (De)serialization progress Pin
Giorgi Dalakishvili8-Apr-08 7:06
mentorGiorgi Dalakishvili8-Apr-08 7:06 
GeneralRe: (De)serialization progress Pin
Stevo Z8-Apr-08 7:13
Stevo Z8-Apr-08 7:13 
GeneralRe: (De)serialization progress Pin
Giorgi Dalakishvili8-Apr-08 7:50
mentorGiorgi Dalakishvili8-Apr-08 7:50 
GeneralRe: (De)serialization progress Pin
Dave Kreskowiak8-Apr-08 7:24
mveDave Kreskowiak8-Apr-08 7:24 
GeneralRe: (De)serialization progress Pin
Stevo Z8-Apr-08 7:37
Stevo Z8-Apr-08 7:37 
QuestionAny customize control like this? Pin
hitdemo8-Apr-08 6:10
hitdemo8-Apr-08 6:10 
GeneralDataGridViewComboBoxCell Problem Pin
Linn728-Apr-08 5:35
Linn728-Apr-08 5:35 
GeneralRe: DataGridViewComboBoxCell Problem Pin
Ravenet8-Apr-08 16:03
Ravenet8-Apr-08 16:03 
GeneralRe: DataGridViewComboBoxCell Problem Pin
Linn728-Apr-08 19:49
Linn728-Apr-08 19:49 
GeneralRe: DataGridViewComboBoxCell Problem Pin
Ravenet8-Apr-08 19:54
Ravenet8-Apr-08 19:54 
GeneralSaveFileDialog filter Pin
lsconyer8-Apr-08 5:11
lsconyer8-Apr-08 5:11 
GeneralRe: SaveFileDialog filter Pin
Dave Kreskowiak8-Apr-08 5:39
mveDave Kreskowiak8-Apr-08 5:39 
Generalissue with scroll sync Pin
Pathetic Logic8-Apr-08 4:48
Pathetic Logic8-Apr-08 4:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.