0
why its giving this output?
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { //You could just do it like this to make it more dynamic: (set the loop condition based on the actual length of the array) int[] a = {1, 2, 3}; for(int i =0; i < a.Length; i++); Console.WriteLine(a); } } } //output = System.Int32[]
2 Answers
+ 1
Console.Writeline(object) calls Tostring method for any object to produce its string representation.
'a' is massive, it is a reference type(object). By default Object.ToString return fully name of the object's type if it is not overrided. For array it is not overrided.
+ 1
I guess you want to display all array values. But your code contains syntax mistake. You code has a extra comma at the end of for loop. Remove it and add index of showings element of array a[i]