Click here to Skip to main content
15,889,992 members
Home / Discussions / C#
   

C#

 
QuestionHow to get to DVD drive without getting access to CD drive? Pin
Khoramdin2-Apr-07 10:16
Khoramdin2-Apr-07 10:16 
Questioncomputer name to IP address Pin
marwan_siala2-Apr-07 9:52
marwan_siala2-Apr-07 9:52 
AnswerRe: computer name to IP address Pin
stancrm2-Apr-07 19:44
stancrm2-Apr-07 19:44 
QuestionOpening UNKNOWN filename? Pin
Goalie352-Apr-07 9:18
Goalie352-Apr-07 9:18 
AnswerRe: Opening UNKNOWN filename? Pin
Christian Graus2-Apr-07 10:01
protectorChristian Graus2-Apr-07 10:01 
AnswerRe: Opening UNKNOWN filename? Pin
engsrini2-Apr-07 13:20
engsrini2-Apr-07 13:20 
QuestionPulling info from arrays Pin
JMOdom2-Apr-07 8:57
JMOdom2-Apr-07 8:57 
AnswerRe: Pulling info from arrays [modified] Pin
Christian Graus2-Apr-07 10:11
protectorChristian Graus2-Apr-07 10:11 
OK, I guess the way to do this, is to use for each to step over your array, and set up a counter for each number you want to track. There are a few ways of doing this, they would include:

create a new array that has the number of elements equal to the highest number in your list, it's an array of numbers, and you set them to 0, and for example, if you find the number 5, you set newArray[5] to be one greater than it was.

Create a struct like this

struct numbers
{
int value;
int times;
}

Then, you create an array of these structs and you find the right one to increment times by.

( the next one is the best )

Dictionary<int, int> times = new Dictionary<int, int>(); // A dictionary is an associative array, we are using numbers, but we can store anything

foreach(int n in numbers)
{

if (!times.KeyExists(n))
{
// Add a key to the dictionary
times[n] = 0;
}

++times[n];
}

Then you can iterate over the keys and use the values to see how many times each one exists.

I suspect this is homework. If it is, then you should do some reading on how the dictionary container works, so you fully understand it. Otherwise, you won't be able to turn the above into code that fully works, nor will you be able to withstand the scrutiny of your teacher when she asks why you did it this way.



-- modified at 18:59 Monday 2nd April, 2007

Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

QuestionHow to remove comment from XML string Pin
AndrusM2-Apr-07 8:05
AndrusM2-Apr-07 8:05 
AnswerRe: How to remove comment from XML string Pin
Not Active2-Apr-07 8:26
mentorNot Active2-Apr-07 8:26 
GeneralRe: How to remove comment from XML string Pin
AndrusM2-Apr-07 9:47
AndrusM2-Apr-07 9:47 
AnswerRe: How to remove comment from XML string Pin
blackjack21502-Apr-07 21:09
blackjack21502-Apr-07 21:09 
GeneralRe: How to remove comment from XML string Pin
AndrusM3-Apr-07 8:49
AndrusM3-Apr-07 8:49 
GeneralRe: How to remove comment from XML string Pin
blackjack21503-Apr-07 21:00
blackjack21503-Apr-07 21:00 
GeneralRe: How to remove comment from XML string Pin
AndrusM4-Apr-07 1:03
AndrusM4-Apr-07 1:03 
GeneralRe: How to remove comment from XML string Pin
AndrusM4-Apr-07 1:13
AndrusM4-Apr-07 1:13 
QuestionFilter a Large Datagrid Pin
Brad Wick2-Apr-07 7:50
Brad Wick2-Apr-07 7:50 
AnswerRe: Filter a Large Datagrid Pin
kubben2-Apr-07 8:30
kubben2-Apr-07 8:30 
GeneralRe: Filter a Large Datagrid Pin
Brad Wick2-Apr-07 12:35
Brad Wick2-Apr-07 12:35 
QuestionDeployment Visual Studio 2005 Error Pin
laura13162-Apr-07 7:30
laura13162-Apr-07 7:30 
Questiontesting of Stored Procedure Pin
sreecahitu2-Apr-07 6:53
sreecahitu2-Apr-07 6:53 
AnswerRe: testing of Stored Procedure Pin
Colin Angus Mackay2-Apr-07 7:15
Colin Angus Mackay2-Apr-07 7:15 
QuestionHow to draw a Horizantal line in WindowsApp Pin
pashitech2-Apr-07 6:23
pashitech2-Apr-07 6:23 
AnswerRe: How to draw a Horizantal line in WindowsApp Pin
maryamf2-Apr-07 9:06
maryamf2-Apr-07 9:06 
QuestionComboBox and BindingSource Pin
mihksoft2-Apr-07 6:15
mihksoft2-Apr-07 6:15 

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.