find and solve || findandsolve.com
Please wait.....

C# String IsInterned()

In the C# IsInterned() method is used to get reference of the specified string. There is some difference between Intern() and IsInterned(). Intern() method interns the string if it is not interned but IsInterned() doesn't do so. In such case, IsInterned() method returns null.

Syntax

public static string IsInterned(String str)  

Parameter

str: it is a string type parameter.

Return

It returns a reference.

C# String IsInterned() Method Example

using System;
public class Program
{
  public static void Main()
    {
           string str = "Hello FindAndSolve";
           string str1 = string.Intern(str);
           string str2 = string.IsInterned(str);
           Console.WriteLine(str);
           Console.WriteLine(str1);
           Console.WriteLine(str2);
    }
}

Output

Hello FindAndSolve

Hello FindAndSolve

Hello FindAndSolve