When the string[], _lineParts is added to the List, all I see in the List is "System.String[]" What needs to be done to see the actually string[] values in the list.
while (_aLine != null) { //split the line read into parts delimited by commas _lineParts = _aLine.Split(new char[] { ' ', '\u000A', ',', '.', ';', ':', '-', '_', '/' }, StringSplitOptions.RemoveEmptyEntries); //keep things going by reading the next line _aLine = sr.ReadLine(); //words = _lineParts; if (_lineParts != null) { //_words.Add(_lineParts.ToString()); wrd.Add(_lineParts.ToString()); } }
Use the Add() method or object initializer syntax to add elements in an ArrayList . An ArrayList can contain multiple null and duplicate values. Use the AddRange(ICollection c) method to add an entire Array, HashTable, SortedList, ArrayList , BitArray , Queue, and Stack in the ArrayList .
First Case, take input values as scanf("%s", input[0]); , similarly for input[1] and input[2] . Remember you can store a string of max size 10 (including '\0' character) in each input[i] . In second case, get input the same way as above, but allocate memory to each pointer input[i] using malloc before.
You can also add an element to String array by using ArrayList as an intermediate data structure. An example is shown below. As shown in the above program, the string array is first converted into an ArrayList using the asList method. Then the new element is added to the ArrayList using the add method.
Use List.AddRange instead of List.Add
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With