Click here to Skip to main content
15,885,767 members
Home / Discussions / C#
   

C#

 
GeneralRe: .NET Rebar Control Error Pin
Heath Stewart12-Jan-04 1:36
protectorHeath Stewart12-Jan-04 1:36 
GeneralRe: .NET Rebar Control Error Pin
David M. Kean12-Jan-04 10:49
David M. Kean12-Jan-04 10:49 
GeneralMix Events Pin
Heroz11-Jan-04 12:35
Heroz11-Jan-04 12:35 
GeneralRe: Mix Events Pin
Colin Angus Mackay11-Jan-04 14:05
Colin Angus Mackay11-Jan-04 14:05 
QuestionHow to simulate map c++ collection in c# Pin
Rostrox11-Jan-04 11:49
Rostrox11-Jan-04 11:49 
AnswerRe: How to simulate map c++ collection in c# Pin
Heath Stewart11-Jan-04 11:54
protectorHeath Stewart11-Jan-04 11:54 
GeneralRe: How to simulate map c++ collection in c# Pin
Rostrox11-Jan-04 12:13
Rostrox11-Jan-04 12:13 
GeneralRe: How to simulate map c++ collection in c# Pin
Heath Stewart11-Jan-04 12:22
protectorHeath Stewart11-Jan-04 12:22 
public struct myTot
{
  public string strDesc;
  public double[] fTots;
}
As you can see, there are a few limitations due to either the language specifications or the .NET Framework.

As far as putting this in a collection or Hashtable, the default, non-specialized implementations take objects as both keys and values. Ever class or value type (which a struct is) derives from System.Object, so you can put a struct in a Hashtable:
myTot tot = new myTot();
tot.strDesc = "blah";
tot.fTots = new double[] {1.2, 3.4};
Hashtable t = new Hashtable();
t["key1"] = tot;
// ...
Console.WriteLine(((myTot)t["key1"]).strDesc);
Read the documentation for the classes in System.Collections about enumerations, collections, lists, and dictionaries. For instance, to enumerate through all the values of a dictionary using the keys, you could do the following:
// Use "t" from example above for hashtable.
IEnumerator e = t.Keys.GetEnumerator();
while (e.MoveNext())
{
  Console.WriteLine("{0}: {1}", e.Current, t[e.Current]);
}
You could also use the foreach keyword for a shortcut:
foreach (object key in t.Keys)
{
  Console.WriteLine("{0}: {1}", key, t[key]);
}


 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
Questionstartup parameters? Pin
Leon Radley11-Jan-04 10:35
Leon Radley11-Jan-04 10:35 
AnswerRe: startup parameters? Pin
Colin Angus Mackay11-Jan-04 10:57
Colin Angus Mackay11-Jan-04 10:57 
AnswerRe: startup parameters? Pin
Heath Stewart11-Jan-04 11:32
protectorHeath Stewart11-Jan-04 11:32 
GeneralRe: startup parameters? Pin
Nick Parker11-Jan-04 11:38
protectorNick Parker11-Jan-04 11:38 
GeneralRe: startup parameters? Pin
Heath Stewart11-Jan-04 11:42
protectorHeath Stewart11-Jan-04 11:42 
QuestionRegEx Guru? Pin
Rocky Moore11-Jan-04 10:13
Rocky Moore11-Jan-04 10:13 
AnswerRe: RegEx Guru? Pin
Heath Stewart11-Jan-04 11:35
protectorHeath Stewart11-Jan-04 11:35 
AnswerRe: RegEx Guru? Pin
Rocky Moore11-Jan-04 16:47
Rocky Moore11-Jan-04 16:47 
GeneralCoding search and replace on content of file Pin
cgcrute11-Jan-04 5:59
cgcrute11-Jan-04 5:59 
GeneralRe: Coding search and replace on content of file Pin
Mazdak11-Jan-04 6:12
Mazdak11-Jan-04 6:12 
GeneralRe: Coding search and replace on content of file Pin
cgcrute11-Jan-04 8:50
cgcrute11-Jan-04 8:50 
GeneralRe: Coding search and replace on content of file Pin
Mazdak11-Jan-04 9:11
Mazdak11-Jan-04 9:11 
GeneralRe: Coding search and replace on content of file Pin
cgcrute11-Jan-04 9:24
cgcrute11-Jan-04 9:24 
GeneralRe: Coding search and replace on content of file Pin
Meysam Mahfouzi11-Jan-04 18:38
Meysam Mahfouzi11-Jan-04 18:38 
GeneralRe: Coding search and replace on content of file Pin
Mazdak11-Jan-04 20:01
Mazdak11-Jan-04 20:01 
GeneralRe: Coding search and replace on content of file Pin
Jonathan de Halleux12-Jan-04 0:06
Jonathan de Halleux12-Jan-04 0:06 
GeneralRe: Coding search and replace on content of file Pin
cgcrute12-Jan-04 0:17
cgcrute12-Jan-04 0:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.