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


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

Updated on: 23-Jun-2020

262 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements