Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this expression a[b] represent in C#

Tags:

c#

I have often seen this expression in a maintenance code

Global["Name"]

What does this represent? I have used Global.Name but never Global["Name"]?

Is there are a place where this type of expression is used?

like image 458
Jack Shephard Avatar asked Nov 21 '25 17:11

Jack Shephard


1 Answers

This is called an indexer. In that case, Global is probably some kind of dictionary or hashtable. "Name" is a key to access a particular item in that dictionary

like image 173
Thomas Levesque Avatar answered Nov 23 '25 07:11

Thomas Levesque