| | |
String Array
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jan 2009
Posts: 68
Reputation:
Solved Threads: 0
Is there any method to find the number of elements that are filled in an array
lets say i have the following array defined
string[] text = new string[50]
and i fill the first 8 elements/indexes
Is there any method that could return the number of elements/indexes within an string array that are filled?
I tried using text.lenght() but that returns the total size of array. In above case it would return 50 which is not what i want...
lets say i have the following array defined
string[] text = new string[50]
and i fill the first 8 elements/indexes
Is there any method that could return the number of elements/indexes within an string array that are filled?
I tried using text.lenght() but that returns the total size of array. In above case it would return 50 which is not what i want...
Hello, gallian99.
I haven't heard about such standard functions
I can offer two alternative ways for you:
1. Using reference types (like ArrayList). You'll able to add elements dynamically and get the actual size of your array.
2. Create your own structure/class, that will contain your array, the full array size (in your case it's 50) and number of added elements.
I haven't heard about such standard functions
I can offer two alternative ways for you:1. Using reference types (like ArrayList). You'll able to add elements dynamically and get the actual size of your array.
2. Create your own structure/class, that will contain your array, the full array size (in your case it's 50) and number of added elements.
So what if you can see the darkest side of me?
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
•
•
Join Date: Jan 2009
Posts: 68
Reputation:
Solved Threads: 0
Thanks Anteka,
I have tackled it using an alternate already. But I should better try ArrayList as well. Haven't work around with it yet
I have tackled it using an alternate already. But I should better try ArrayList as well. Haven't work around with it yet

•
•
•
•
Hello, gallian99.
I haven't heard about such standard functionsI can offer two alternative ways for you:
1. Using reference types (like ArrayList). You'll able to add elements dynamically and get the actual size of your array.
2. Create your own structure/class, that will contain your array, the full array size (in your case it's 50) and number of added elements.
If you are running on .NET 3, you can use Lists, which are very easy:
C# Syntax (Toggle Plain Text)
List<String> strings = new List<String>(); //initialise the list strings.Add(str); //Add an item int length = strings.Count; //how many strings are in the list.
•
•
Join Date: Feb 2008
Posts: 46
Reputation:
Solved Threads: 4
hi
u can do this
bye
u can do this
C# Syntax (Toggle Plain Text)
int counter=0; // global value while(true) { if (s[counter] != null) { comboBox1.Items.Add(s[counter]); counter++; } else { break; } }
bye
try this ??? is easy way to find
C# Syntax (Toggle Plain Text)
int I = 0; foreach (string S in Text) { int I += 1; } Console.WriteLine(I.ToString());
Delphi & C# programmer deluxe...
![]() |
Similar Threads
- How do I convert a vector to a String array ? (Java)
- Declaring string array, initializing later... (C++)
- Copy string into an array (C#)
- ArrayList to multi-dimensional string array (C#)
- Geting elements from a String Array (C++)
Other Threads in the C# Forum
- Previous Thread: Platform Builder and C#
- Next Thread: Help with RegEx and matchcollection screen scraping
| Thread Tools | Search this Thread |
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# check checkbox client color combo combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees developer development draganddrop drawing encryption enum equation event excel file files form format forms function gdi+ httpwebrequest image index input install java label list listbox listener mandelbrot math mathematics mouseclick mysql nargalax operator path photoshop picturebox pixelinversion post programming radians regex remote remoting restore richtextbox save saving serialization server sleep socket sql stack statistics stream string table tcp text textbox thread time timer update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






