[Closed] c# set array[i] in maxscript
Considering a c# class that have an array property, say something like that :
public class MyClass
{
public string[] MyArray { get; set; }
}
Withing Maxscript, I can access and set the array quiete easily like that:
myClass = dotNetObject "MyAssembly.MyClass"
myClass.MyArray
[I]return undefined[/I]
myClass.MyArray = #("hello", "world")
myClass.MyArray
[I]return #("hello", "world")[/I]
myClass.MyArray[1]
[I]return "hello"[/I]
But if I can’t set individual item like that:
myClass.MyArray[1] = "test"
myClass.MyArray[1]
[I]return "hello"[/I]
Debuging in Visual Studio showed me that the call was going into the “get” instead of the “set”
Any idea how to make this works ?
Thanks for the answer. I know that I can use SetValue(value, index) to do this (and apparently going to have to)
My question was more about why setting the value with the indexing operator doesn’t work while I can get / set the whole array and get a specific value with the indexing operator, just for the sake of understanding, which could help me make this work
I guess it was just neglected to be implemented as a setter for .NET array by the Maxscript devs when .NET support was added to Maxscript. I can’t imagine any other reason.