OPC Studio User's Guide and Reference
ToString() Method
Example 



OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA Namespace > UAStatusCode Class > ToString Method : ToString() Method
Converts the various fields of a status code to a string.
Syntax
'Declaration
 
<NotNullAttribute()>
Public Overloads Overrides NotOverridable Function ToString() As String
'Usage
 
Dim instance As UAStatusCode
Dim value As String
 
value = instance.ToString()
[NotNull()]
public override string ToString()
[NotNull()]
public:
String^ ToString(); override 

Return Value

Returns the status code converted to a string.

This method never returns null (Nothing in Visual Basic).

This method can return null (Nothing in Visual Basic).

Remarks

This method or property does not throw any exceptions, aside from execution exceptions such as System.Threading.ThreadAbortException or System.OutOfMemoryException.

Example
// This example shows how the OPC UA status codes are formatted to a string containing their symbolic name.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using OpcLabs.EasyOpc.UA;

namespace UACommonDocExamples._UAStatusCode
{
    class ToString
    {
        public static void Main1()
        {
            long[] internalValueArray = { 0, 0x80010000, 2147614720, 0x80340000 };

            foreach (long internalValue in internalValueArray)
                Console.WriteLine($"{internalValue}: {new UAStatusCode(internalValue)}");


            // Example output:
            //0: Good
            //2147549184: BadUnexpectedError
            //2147614720: BadInternalError
            //2150891520: BadNodeIdUnknown
        }
    }
}
' This example shows how the OPC UA status codes are formatted to a string containing their symbolic name.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.

Imports OpcLabs.EasyOpc.UA

Namespace _UAStatusCode
    Partial Friend Class ToString
        Public Shared Sub Main1()
            Dim internalValueArray() As Long = {0, &H80010000&, 2147614720, &H80340000&}

            For Each internalValue As Long In internalValueArray
                Console.WriteLine($"{internalValue}: {New UAStatusCode(internalValue)}")
            Next internalValue


            ' Example output:
            '0: Good
            '2147549184 BadUnexpectedError
            '2147614720: BadInternalError
            '2150891520: BadNodeIdUnknown
        End Sub
    End Class
End Namespace
# This example shows how the OPC UA status codes are formatted to a string containing their symbolic name.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from System import *
from OpcLabs.EasyOpc.UA import *


internalValueArray = [0, 0x80010000, 2147614720, 0x80340000]

for internalValue in internalValueArray:
    print(internalValue, ': ', UAStatusCode(internalValue), sep='')

print()
print('Finished.')


# Example output:
# 0: Good
# 2147549184: BadUnexpectedError
# 2147614720: BadInternalError
# 2150891520: BadNodeIdUnknown
#
# Finished.
Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also