LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.Net Constructor Modify Value

 

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?

0 Kudos
Message 1 of 4
(169 Views)

 

IntPtr.png

0 Kudos
Message 2 of 4
(156 Views)

Hi,

 

Use the functions from the .NET palette:

 - To .NET Object.vi

 - .NET Object To Variant.vi

raphschru_1-1733673723918.png

It will only work for basic LabVIEW data types.

See my answer here for more details:

https://forums.ni.com/t5/LabVIEW/Why-use-the-NET-Object-to-Variant-and-To-NET-Object-VIs/m-p/4339456...

 

Regards,

Raphaël.

0 Kudos
Message 3 of 4
(107 Views)

@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.

 

Value Types vs Reference Types in C#

Built-in types - C# reference | Microsoft Learn

0 Kudos
Message 4 of 4
(83 Views)