I’m porting code which uses alot of SetValue and GetValue methods

I’ve figure out how to do extensions for strings but still learning how to do them for arrays.

At bottom of this post is an extension for SetAllValues I found on the web.

I’m trying to rewrite for SetValue and GetValue.

So will this work? I’m concerned that the second parameter (value) needs to be declared as byte but I’m not sure. Any help is greatly appreciated as I’m still learning.

Thanks

```
public static T[] SetValue<T>(this T[] array, T value, int index)
{
array[index] = value;
return array;
}
```

Example for SetAllValues

```
/// <summary>
/// Sets all values.
/// </summary>
/// <typeparam name="T">The type of the elements of the array that will be modified.</typeparam>
/// <param name="array">The one-dimensional, zero-based array</param>
/// <param name="value">The value.</param>
/// <returns>A reference to the changed array.</returns>
public static T[] SetAllValues<T>(this T[] array, T value)
{
for (int i = 0; i < array.Length; i++)
{
array[i] = value;
}
return array;
}
```