0

what is the diffrence of my code with code in the site(indexers)

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace test { class client { private string[] names = new string[10]; public string[] Name { get { return names; } set { names = value; } } } class Program { static void Main(string[] args) { client c = new client(); c.Name[0] = "dave"; c.Name[1]="bob"; Console.WriteLine(c.Name[1]); Console.ReadKey(); } } }

9th Dec 2016, 9:36 PM
mohammad
1 Réponse
0
The difference is that you have to access the property which is an array of strings. The example code makes the class directly accessible through an indexer.
11th Dec 2016, 1:19 PM
Leon Lichtblau
Leon Lichtblau - avatar