How to build lookup table with an array as one of the elements?

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi,

I need to build a BAUDOT lookup table for an encoder. I see to use a
char as the index 'A' or 'B' and get back an array of booleans (five
elements long).

Baudot['A'] = {00011}
Baudot['B'] = {11001}

Can someone give me a pointer on how to build this as a static lookup
table?

Do I want an array of arrays?

public static bool [][] = {'A', {0, 0, 0, 1, 1, 1} };

This isn't right because an A is not a bool.

Maybe an array of structures?

How do I initiale the structure boolean array?

Thanks,
John
 
John said:
I need to build a BAUDOT lookup table for an encoder. I see to use a
char as the index 'A' or 'B' and get back an array of booleans (five
elements long).

Baudot['A'] = {00011}
Baudot['B'] = {11001}

Can someone give me a pointer on how to build this as a static lookup
table?

It sounds to me as if you don't want an array, you want a map - look at
Hashtable.
 
Hi John,

I think you can do something like this:

Hashtable ht=new Hashtable();
ht.Add('A',new byte[]{0,0,0,1,1});
ht.Add('B',new byte[]{1,1,0,0,1});
byte [] arr1=(byte[])ht['A'];
byte [] arr2=(byte[])ht['B'];

Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: (e-mail address removed) (John)
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Subject: How to build lookup table with an array as one of the elements?
| Date: 27 Oct 2003 11:49:10 -0800
| Organization: http://groups.google.com
| Lines: 24
| Message-ID: <[email protected]>
| NNTP-Posting-Host: 192.25.240.225
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1067284150 20939 127.0.0.1 (27 Oct 2003
19:49:10 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: Mon, 27 Oct 2003 19:49:10 +0000 (UTC)
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!postnews1.google.com!no
t-for-mail
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:194480
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Hi,
|
| I need to build a BAUDOT lookup table for an encoder. I see to use a
| char as the index 'A' or 'B' and get back an array of booleans (five
| elements long).
|
| Baudot['A'] = {00011}
| Baudot['B'] = {11001}
|
| Can someone give me a pointer on how to build this as a static lookup
| table?
|
| Do I want an array of arrays?
|
| public static bool [][] = {'A', {0, 0, 0, 1, 1, 1} };
|
| This isn't right because an A is not a bool.
|
| Maybe an array of structures?
|
| How do I initiale the structure boolean array?
|
| Thanks,
| John
|
 
Thanks!

"Jeffrey Tan[MSFT]" said:
Hi John,

I think you can do something like this:

Hashtable ht=new Hashtable();
ht.Add('A',new byte[]{0,0,0,1,1});
ht.Add('B',new byte[]{1,1,0,0,1});
byte [] arr1=(byte[])ht['A'];
byte [] arr2=(byte[])ht['B'];

Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: (e-mail address removed) (John)
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Subject: How to build lookup table with an array as one of the elements?
| Date: 27 Oct 2003 11:49:10 -0800
| Organization: http://groups.google.com
| Lines: 24
| Message-ID: <[email protected]>
| NNTP-Posting-Host: 192.25.240.225
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1067284150 20939 127.0.0.1 (27 Oct 2003
19:49:10 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: Mon, 27 Oct 2003 19:49:10 +0000 (UTC)
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-online.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!postnews1.google.com!no
t-for-mail
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:194480
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Hi,
|
| I need to build a BAUDOT lookup table for an encoder. I see to use a
| char as the index 'A' or 'B' and get back an array of booleans (five
| elements long).
|
| Baudot['A'] = {00011}
| Baudot['B'] = {11001}
|
| Can someone give me a pointer on how to build this as a static lookup
| table?
|
| Do I want an array of arrays?
|
| public static bool [][] = {'A', {0, 0, 0, 1, 1, 1} };
|
| This isn't right because an A is not a bool.
|
| Maybe an array of structures?
|
| How do I initiale the structure boolean array?
|
| Thanks,
| John
|
 
Back
Top