find and solve ||
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.


public static string IsInterned(String str)  


str: it is a string type parameter.


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);


Hello FindAndSolve

Hello FindAndSolve

Hello FindAndSolve