×

VB.Net Programs

VB.Net program to demonstrate the Intern() method of String class

By Nidhi Last Updated : November 11, 2024

String.Intern() Method in VB.Net

The Intern() method is used to system's reference to the specified string.

Syntax

Function Intern(ByVal str as String) as String

Parameter(s)

  • Str: Specified string.

Return Value

It returns the system's reference to the specified string.

VB.Net code to demonstrate the example of String.Intern() method

The source code to demonstrate the Equals() method of the String class is given below. The given program is compiled and executed successfully.

'VB.NET program to demonstrate the Intern() 
'method of String class.

Imports System

Module Module1
    Sub Main()
        Dim str1 As String = "hello World"
        Dim str2 As String = "Hello World"

        Console.WriteLine("System's reference of str1 #{0}#", String.Intern(str1))
        Console.WriteLine("System's reference of str2 #{0}#", String.Intern(str2))
    End Sub
End Module

Output

System's reference of str1 #hello World#
System's reference of str2 #Hello World#
Press any key to continue . . .

Explanation

In the above program, we created a module Module1 that contains the Main() function. The Main() function is the entry point for the program.

In the Main() function, we created two strings str1 and str2. Here, we get the system's reference of the specified strings and print the result on the console screen.

VB.Net String Programs »


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.