HAY people

ive created the code as below but when i run the program it is displaying: system.Array[] or somthing like that instead of the value in the array.

I though it mite be a problem when converting the string[] to string but i cant seem to find a solution. any ideas???

public static void Main(string[] args)
        {
            string[] tracearray = Tracetoarray();
            Console.Write(tracearray[0]);
            Console.ReadKey();
        }

        private static string[] Tracetoarray()
        {
            string Trace = File.ReadAllText(@"C:\Users\Mark\Desktop\University\Final Year Project\TEST FILE.csv");

            string[] Trace_Lines = Trace.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

            int row = 5;

            string[] TraceArray = new string[row];

            for (int j = 0; j < Trace_Lines.Length-1; j++)
            {
                string TraceResults = Convert.ToString(Trace_Lines);
                TraceArray[j] = TraceResults;
                

            }

            return TraceArray;
        }

Thank you

Instead of reading whole text, and then split the lines, you can get all lines into an array directly:

string[] lines = File.ReadAllLines(@"C:\file.txt");

Instead of reading whole text, and then split the lines, you can get all lines into an array directly:

string[] lines = File.ReadAllLines(@"C:\file.txt");

oh thanks. i still cant get it to display the result.

oh thanks. i still cant get it to display the result.

ok thanks that helped i got it sorted

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.