# Compile error for vtkFloatArray.SetValue

**URL:** https://discourse.vtk.org/t/compile-error-for-vtkfloatarray-setvalue/12182
**Category:** Support
**Created:** [August 23, 2023, 3:10am UTC](https://discourse.vtk.org/t/compile-error-for-vtkfloatarray-setvalue/12182 "2023-08-23T03:10:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![liuzhongshu](https://discourse.vtk.org/user_avatar/discourse.vtk.org/liuzhongshu/32/6921_2.png) [@liuzhongshu](https://discourse.vtk.org/u/liuzhongshu)
#### Post date: [August 23, 2023, 3:10am UTC](https://discourse.vtk.org/t/compile-error-for-vtkfloatarray-setvalue/12182/1 "2023-08-23T03:10:11Z")

</div>

I tried to build an c# example of vtk-examples: src\CSharp\PolyData\NullPoint.cs using [Activiz.NET](http://Activiz.NET) 9, but get a compile error for SetValue:

```auto
vtkFloatArray floatArray = vtkFloatArray.New();
         floatArray.SetNumberOfValues(3);
         floatArray.SetNumberOfComponents(1);
         floatArray.SetName("FloatArray");
         for(int i = 0; i < 3; i++) {
            floatArray.SetValue(i, 2);
         }

```

Program.cs(27, 24): [CS1061] ‘vtkFloatArray’ does not contain a definition for ‘SetValue’ and no accessible extension method ‘SetValue’ accepting a first argument of type ‘vtkFloatArray’ could be found (are you missing a using directive or an assembly reference?)

Am I wrong?

---

<div class="post-metadata">

### Author: ![liuzhongshu](https://discourse.vtk.org/user_avatar/discourse.vtk.org/liuzhongshu/32/6921_2.png) [@liuzhongshu](https://discourse.vtk.org/u/liuzhongshu)
#### Post date: [August 25, 2023, 3:05am UTC](https://discourse.vtk.org/t/compile-error-for-vtkfloatarray-setvalue/12182/2 "2023-08-25T03:05:57Z")

</div>

I can change the code to SetTuple1 to make the code compile, but the parameter of SetTurple1 is always double, Will this lose precision? For example, for a vtkIntArray

```auto
vtkIntArray intArray = vtkIntArray.New();
intArray.SetNumberOfValues(3);
intArray.SetNumberOfComponents(1);
for(int i = 0; i < 3; i++) {
    intArray.SetTuple1(i, 2); // the value is convert to double
}

```

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [August 25, 2023, 10:32am UTC](https://discourse.vtk.org/t/compile-error-for-vtkfloatarray-setvalue/12182/3 "2023-08-25T10:32:33Z")

</div>

There are different ways to populate data arrays. This is due to historical, convenience, and wrapping (e.g., Python) reasons. Using variations of SetTuple\* is convenient and simple, but may have performance and precision effects as you point out. As a result, there are more complex, performance oriented ways to populate VTK data arrays. For example, using templated dispatch. Take a look at [https://docs.vtk.org/en/latest/design\_documents/array\_dispatch.html](https://docs.vtk.org/en/latest/design_documents/array_dispatch.html). I would also suggest looking at source code (such as vtkWarpVector). Note that templated dispatch is often used in conjunction with vtkSMPTools to implement threaded processing. (There are other ways to do the same thing such as GetPointer(), but this typically is discouraged as you need to know the type and organizational structure of the data array i.e., SOA or AOS).
