Table of Contents

Class VL_Strings

Namespace
VirtualLab.Programming
Assembly
VirtualLab.Programming.dll

This class provides methods for converting VirtualLab objects to a string.

public static class VL_Strings
Inheritance
VL_Strings
Inherited Members

Methods

ToString(double, PhysicalProperty, int)

Converts a floating point number in double precision to a string.

public static string ToString(double doubleValue, PhysicalProperty physicalProperty = PhysicalProperty.NoUnit, int numberOfDigits = 2147483647)

Parameters

doubleValue double

The double value to convert.

physicalProperty PhysicalProperty

This optional parameter allows you to set the PhysicalProperty used for the output. For example a wavelength is formatted as “532 nm” instead of “5.32e-7” if this parameter is set to PhysicalProperty.Length.

numberOfDigits int

Optional parameter to set the number of digits shown in the string. If this parameter is not specified, the precision set in the Global Options dialog is used.

Returns

string

The double value as string.

ToString(int, bool)

Converts an integer value to a string.

public static string ToString(int integer, bool useGroupSeparator = false)

Parameters

integer int

The integer value to convert.

useGroupSeparator bool

If this optional parameter is set to true, the integer 1234567 is converted to “1'234'567”.

Returns

string

The integer value as string.

ToString(Complex, PhysicalProperty, int, ComplexToStringConversionFormat)

Converts a complex value to a string.

public static string ToString(Complex complexValue, PhysicalProperty physicalProperty = PhysicalProperty.NoUnit, int numberOfDigits = 2147483647, ComplexToStringConversionFormat conversionFormat = ComplexToStringConversionFormat.AmplitudePhase)

Parameters

complexValue Complex

The Complex value to convert.

physicalProperty PhysicalProperty

This optional parameter allows you to set the PhysicalProperty used for the output. For example a complex amplitude is formatted as “1 µV/m· exp(i·2)” instead of “1e-6· exp(i·2)” if this parameter is set to PhysicalProperty.ElectricalField.

numberOfDigits int

Optional parameter to set the number of digits shown in the string. If this parameter is not specified, the precision set in the Global Options dialog is used.

conversionFormat ComplexToStringConversionFormat

Optional parameter to specify the format of the complex number. If you set this parameter to ComplexToStringConversionFormat.RealImaginary, the value is formatted as “{Real} + {Imaginary}·i”. If you set it to ComplexToStringConversionFormat.AmplitudePhase (the default), the value is formatted as “{Amplitude}· exp(i·{Phase})”.

Returns

string

The complex value as string.

ToString(PhysicalValue, int, bool, bool)

Converts a physical value to a string.

public static string ToString(PhysicalValue physicalValue, int numberOfDigits = 2147483647, bool showPhysicalUnits = true, bool prependComment = false)

Parameters

physicalValue PhysicalValue

The PhysicalValue object to convert.

numberOfDigits int

Optional parameter to set the number of digits shown in the string. If this parameter is not specified, the precision set in the Global Options dialog is used.

showPhysicalUnits bool

If this optional parameter is set to false, no units are shown which can be useful if you want to to use the string in other programs not supporting physical units. For example a wavelength is then formatted as “5.32e-7” instead of “532 nm”.

prependComment bool

If this optional parameter is set to true, the comment of the physical value is prepended. This means that the string is formatted as “{Comment} of {Value [with units]}” (e. g. “wavelength of 300 nm”).

Returns

string

The physical value as string.

ToString(PhysicalValueComplex, int, bool, bool, ComplexToStringConversionFormat)

Converts a complex physical value to a string.

public static string ToString(PhysicalValueComplex physicalValue, int numberOfDigits = 2147483647, bool showPhysicalUnits = true, bool prependComment = false, ComplexToStringConversionFormat conversionFormat = ComplexToStringConversionFormat.AmplitudePhase)

Parameters

physicalValue PhysicalValueComplex

The PhysicalValue object to convert.

numberOfDigits int

Optional parameter to set the number of digits shown in the string. If this parameter is not specified, the precision set in the Global Options dialog is used.

showPhysicalUnits bool

If this optional parameter is set to false, no units are shown which can be useful if you want to to use the string in other programs not supporting physical units.

prependComment bool

If this optional parameter is set to true, the comment of the physical value is prepended. This means that the string is formatted as “{Comment} of {Value [with units]}” (e. g. “complex amplitude of 1·exp(2) V/m”).

conversionFormat ComplexToStringConversionFormat

Optional parameter to specify the format of the complex number. If you set this parameter to ComplexToStringConversionFormat.RealImaginary, the value is formatted as “{Real} + {Imaginary}·i”. If you set it to ComplexToStringConversionFormat.AmplitudePhase (the default), the value is formatted as “{Amplitude}· exp(i·{Phase})”.

Returns

string

The complex physical value as string.