0

How do I do a get/post for an array in c#?

In C#, you get and set variables like this:

`public int ID { get; set; }`

How would one get and set an array in C#?

This will not work:

`public uint [5] BIG_Hash {get; set;}`
3
Contributors
5
Replies
11
Views
5 Years
Discussion Span
Last Post by ddanbe
0
public uint[] BIG_Hash { get; set; }

...

obj.BIG_Hash = new uint[5]; // set

uint[] temp = obj.BIG_Hash; // get

The size is an attribute of the actual attached to the underlying object, not the object reference.

0

I kind of remember that I need separate methods for the set and get too that lines 5 and 7 need to be inside of.

0

I kind of remember that I need separate methods for the set and get too that lines 5 and 7 need to be inside of.

Yes, the "..." part is a placeholder for intervening code. Since it wouldn't compile, that's meant to show that this is a snippet. I used it so that I could highlight just the important lines of defining the property and using each of the get and set parts without junking up the example with boilerplate.

Edited by deceptikon

0

I vaguely remember using this in some code but it was long ago. How would the Get and Set methods look like? And how would the surrounding code be structured? Can I get a more complete picture?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.