16
Answers

null values in a string array

calfson

calfson

20y
14.2k
1
I have a code that reads in a text file of numbers that are both tab delimited as well as a carriage return at the end of each line. I have read the file into a string array, but the array does not get rid of the null values. How do I do this? Here is what I have thus far. Thanks for any help! using System; using System.IO; using System.Collections; namespace try_again { class Class1 { static void Main(string[] args) { StreamWriter swa = new StreamWriter ("c:\\afinal.txt"); StreamReader sra = new StreamReader ("c:\\ChristineWork\\test1.txt"); string aLine = sra.ReadToEnd(); string[] TokenBuffer = aLine.Split(new Char [] {' '}); foreach(string token in TokenBuffer) { if(token.Length !=0) Console.WriteLine(token); } Console.ReadLine(); sra.Close();
Answers (16)