How to use the ToString() method of array in C#?

CsharpProgrammingServer Side Programming

The ToString() method returns a string that represents the current object.

In the below example, we have used the ToString() method with another Array class method.

arr.GetLowerBound(0).ToString()

Example

 Live Demo

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace lower {
   class Program {
      static void Main(string[] args) {
         Array arr = Array.CreateInstance(typeof(String), 3);
         arr.SetValue("One", 0);
         arr.SetValue("Two", 1);
         Console.WriteLine("Lower Bound {0}",arr.GetLowerBound(0).ToString());
         Console.ReadLine();
      }
   }
}

Output

Lower Bound 0
raja
Published on 18-Sep-2018 13:32:12
Advertisements