Access data types in collections by reference

M

Mitja Semolic

// Example

public struct SomeData
{
public int X;
public int Y;

public SomeData(int x, int y)
{ ... }
}

....

Hashtable table = new Hashtable();
SomeData sd = new SomeData(1, 2)
table.Add(1, sd);


// this of course does not work, cause is passed by value
// but is there a way, or I need a class to encapsulate data types (stupid
solution)

((SomeData)table[1]).X = 2;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top