|
What do you mean ?
Array.Length ?
|
|
|
|
|
No, example:
using System;
class Alkalmazas {
public static void Main() {
int[] array = new int[10];
array[0] = 1;
array[1] = 1;
array[2] = 1;
array[3] = 2;
array[4] = 1;
array[5] = 2;
array[6] = 1;
array[7] = 1;
array[8] = 2;
array[9] = 3;
Console.WriteLine(array.?); // output: '1' occurrence is 6
Console.WriteLine(array.?); // output: '2' occurrence is 3
Console.WriteLine(array.?); // output: '3' occurrence is 1
}
}
|
|
|
|
|
In that case, use a Dictionary or Hashtable
|
|
|
|
|
Array items are not optional. An arrays has a fixed size, and every item in the array has a value.
If you mean an array of references where you have null values, there is no built-in method for the special case of counting non-null items in arrays of references.
---
single minded; short sighted; long gone;
|
|
|
|
|
Look at Array.FindAll(), you can use the resulting array's length, eg:
int[] result = Array.FindAll(inputArr, delegate(int i) { return i > 5; });
Console.WriteLine(result.Length);
|
|
|
|
|
Yes, I gave a thought to this. Thank you very much, indeed!
|
|
|
|
|
Apart from leppie's solution you might want to have a look at the free PowerCollections library.
PowerCollections[^]
Then you can do:
int[] array = new int[10];
array[0] = 1;
array[1] = 1;
array[2] = 1;
array[3] = 2;
array[4] = 1;
array[5] = 2;
array[6] = 1;
array[7] = 1;
array[8] = 2;
array[9] = 3;
int count1 = Algorithms.CountWhere(array, delegate(int i) { return i == 1; });
Console.WriteLine("Count = {0}", count1);
int count2 = Algorithms.CountWhere(array, delegate(int i) { return i == 2; });
Console.WriteLine("Count = {0}", count2);
int count3 = Algorithms.CountWhere(array, delegate(int i) { return i == 3; });
Console.WriteLine("Count = {0}", count3);
PowerCollections consists of additional data structures and algorithms, somewhat similar to C++'s STL. It's very easy to use. Just reference the DLL and add a using statement. It was written by a former member of the C# team and went though quite a lot of beta testing. There is another possibly more advanced library called C5, which I've never used.
Kevin
|
|
|
|
|
Hi i am using ndoc tool to document my application. In my application i have 10-12 classes and one class is a testing class where i have created small methods just to test the different functionalities of application.
Well to create document with ndoc i needed .dll file for which i created .dll via
project properties-> application-> ouput type-> class library..
Now when i create document via ndoc it only creates my testing class document. Icluding all the testing methods i wrote. But what about the rest of the classes.
Have i created .dll correctly.
In xml file it gives info about rest of the classes. but why not via ndoc...yeh through main method i am calling only that testing class and its methods..
Any one here familiar with NDOC...?
Thanks
|
|
|
|
|
NDoc config by default leaves out privent members. Are your classes non-public? If that's not the issue, then I don't know.
|
|
|
|
|
yeh all the classes member variables are private..so this is the reason its not including all the classes..... well any way out so that it includes everything..
thanks
|
|
|
|
|
Look at the various settings in the NDoc GUI. You should be able to get everything that you need. I assume you are using VS 2003/.NET1.1 because .NET 2.0 is not officially supported in NDoc.
Kevin
|
|
|
|
|
yeh i changed few settings from NDoc GUI and it worked...And yeh i am using VS 2005 and it is supporting. Yeh officially this project is closed and no more update would be available for this.
Thanks
|
|
|
|
|
If you run into problems with NDoc then MS's Sandcastle[^] is the way to go. I haven't tried it myself yet though.
Kevin
|
|
|
|
|
I believe NDoc has an option to include privates though. I wouldn't change code just so that they show.
|
|
|
|
|
Hi,
I have two datatables the first consists of 4 columns Name, Test1, Test2, Test3 and numerous rows
and the second consists of 4 columns
Result, Test1, Test2, Test3
Min,?, ?, ?
Max,?, ?, ?
Average,?, ?, ?
So basically I need to fill the second table with the Min, Max and Average of the tests in the first table im not quite sure what the best way to go about this is so any help of advice would be appreciated
Thanks in advance
Tim
|
|
|
|
|
tadhg88 wrote: im not quite sure what the best way to go about this is so any help of advice would be appreciated
Pay attention in class, or ask your professor.
only two letters away from being an asset
|
|
|
|
|
ya its too late for that im afraid, 2 years 2 late infact
so any ideas no???
|
|
|
|
|
Hi
I want to send a string to MSMQ.But when i call the send method its showing me an error Format is not valid.Can any one help me on solving this issue
I have written only this much code
System.Messaging.Message mm = new System.Messaging.Message();
MessageQueue mq = new System.Messaging.MessageQueue(XMLMSMQPath);
mq.Formatter = new XmlMessageFormatter(new String[] { "System.String,mscorlib" });
mm.Body = xmlFileName;
what do i need for this.Please help me in this
mm.Label = "FileNames";
mq.Send(mm);
Regards
DilipRam
|
|
|
|
|
message.Formatter = new BinaryMessageFormatter(System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple, System.Runtime.Serialization.Formatters.FormatterTypeStyle.TypesAlways);
Thats what I use and it seems to always work. This is assuming that you don't want XML formatting for a particular reason.
|
|
|
|
|
Hi thanks for the reply..but still format invalid error arises..
the code which i am executing is
System.Messaging.Message mm = new System.Messaging.Message();
MessageQueue mq = new System.Messaging.MessageQueue(XMLMSMQPath);
mm.Formatter = new BinaryMessageFormatter(System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple, System.Runtime.Serialization.Formatters.FormatterTypeStyle.TypesAlways);
mm.Body = xmlFileName;
mm.Label = "FileNames";
mq.Send(mm);
but at the mq.send(mm) it is showing formatname is invalid...
Please help me..Am i missing any thing in this code..
Regards
DilipRam
|
|
|
|
|
hi
how can i place my program icon into desktop toolbox?
|
|
|
|
|
hi ,
I'm not entirely sure what you mean by Desktop **toolbox!?
If you mean the Visual Studio toolbox you need to add the ToolBoxBitmap attribute over the class:
[System.Drawing.ToolboxBitmap("c:\\stop.bmp")]
class MyStopControl
{
}
If you mean the StartMenu , then check out deployment in .NET (search google)
Gideon
|
|
|
|
|
hi
so thanks for your help
|
|
|
|
|
Hi,
Is Nothing (in VB.NET) and null (in C#) the same thing? Why I ask is because I saw a piece of VB code where they set a DateTime value equal to nothing. Now I know that DateTime can't be equal to null.
Regards
ma se
|
|
|
|
|
ma se wrote: Is Nothing (in VB.NET) and null (in C#) the same thing?
Yes.
Interesting. You're right, it works in VB but not C#, I wonder what the reason for that is.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|