faqts : Computers : Programming : Languages : C#

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

11 of 17 people (65%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

Writing a PERL hash the C# way

Feb 22nd, 2004 18:19
Cleave Pokotea - www.makethingstalk.co.nz,


I would like to Initialize Hash (Array?) Elements in C# as in perl e.g:

my %KeyVal = (1, "A",2, "B");

That is, with mixed types.  Is this possible?

I know in C# you can do:

Hashtable hTable = new Hashtable();
hTable.Add("1","A");
hTable.Add("2","B");

to create a hash, but is the following possible?

namespace x{
 public class xC{
  prinvate Hashtable xHashTable = (1, "A", 2, "B");
  
  public xC{
    // use xHashTable somehow ...
  }
 }
}