12-07-2024 02:25 PM
Hello,
I have a general question about the LabVIEW implementations in .Net. For classes that have a constructor with parameter inputs, LabVIEW can set values for the instance. An example is the mscorlib-->System-->IntPtr case, where you can select, for example, Int32 as a input. LabVIEW then has a node where you can initialize the instance with a value. This is shown on the left in the attached.
Is there any way to change the value of an instance where there are no constructor parameters or methods to do so? As a example, try the mscorlib-->System-->Int16, as shown on the right in the attached. Is there any way to write a new value to that instance in LabVIEW?
In C#, for example, I would use something like the following:
mscorlib.System.Int16 MyVar = 20
There is no explicit constructor, but I can still initialize it with a value. Is there some equivalent to this in LabVIEW?
12-07-2024 03:53 PM
12-08-2024 10:04 AM
Hi,
Use the functions from the .NET palette:
- To .NET Object.vi
- .NET Object To Variant.vi
It will only work for basic LabVIEW data types.
See my answer here for more details:
Regards,
Raphaël.
12-09-2024 07:10 AM
@immercd1 wrote:Is there any way to change the value of an instance where there are no constructor parameters or methods to do so? As a example, try the mscorlib-->System-->Int16, as shown on the right in the attached. Is there any way to write a new value to that instance in LabVIEW?
.NET has value types and reference types.. A .NET Int16 is a (build-in) value type. .NET value types are by value, so it's not a reference to an instance like 'normal' .NET objects.
I think that's why there's no method to change the value: in .NET languages that would be very confusing.