Click here to Skip to main content
15,892,965 members
Home / Discussions / C#
   

C#

 
GeneralExport DataGrid from different dynamically created tabpages to multiple worksheets of an Excel spreasheet Pin
Walaza8-Apr-08 7:09
Walaza8-Apr-08 7:09 
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 
My bad... sorry. I think the knowledge representation is the tricky part here. Once you figure out how to represent the information, the rest is a snap. Have a look, there are many ways to implement this. So I put together an example using .NET 3.5 as to what you can do. If you're using 2.0, you'll have to make the Action and Predicate delegate yourself, but it will work the same. The code will compile and run.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CountTest {
    class Program {
        static void Main(string[] args) {
            String test = "1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9";
            List<bucket> items = new List<bucket>();
            String[] split = test.Split(',');
            foreach (String s in split) {
                Bucket b = new Bucket{ Key = s, Count = 1}; // if we have a key it's count is already 1
                Bucket searchedBucket = items.Find(new Predicate<bucket>(bkt => b.Key.Equals(bkt.Key)));
                if (searchedBucket == null) { // add it in new
                    items.Add(b);
                } else { // increment
                    searchedBucket.Count++;
                }
            }
            //print to console
            items.ForEach(new Action<bucket>(b => Console.WriteLine(b.ToString())));

            Console.ReadLine();
        }
    }

    public class Bucket {
        public string Key;
        public Int32 Count;
        public override string ToString() {
            return String.Format("{0} {1}{2}", Count, Key, Count > 1 ? "'s" : "");
        }
    }
      
}
/* OUTPUT
1 1
2 2's
3 3's
4 4's
5 5's
6 6's
7 7's
8 8's
9 9's

*/

</bucket></bucket></bucket></bucket>


Scott

"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand

GeneralRe: Checking integer values and adding same types together Pin
Dave Kreskowiak8-Apr-08 7:55
mveDave Kreskowiak8-Apr-08 7:55 
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 

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.