- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to retrieve the system’s reference to the specified String in C#?
To retrieve the system’s reference to the specified String, the code is as follows −
Example
using System; public class Demo{ public static void Main(string[] args){ string str1 = "David"; string str2 = string.Intern(str1); Console.WriteLine("String1 = "+str1); Console.WriteLine("System reference of String1 = "+str2); } }
Output
This will produce the following output −
String1 = David System reference of String1 = David
Example
Let us now see another example −
using System; public class Demo{ public static void Main(string[] args){ string str1 = "50"; string str2 = "100"; Console.WriteLine("String1 = "+str1); Console.WriteLine("String2 = "+str2); str2 = string.Intern(str1); Console.WriteLine("System reference of String1 = "+str2); } }
Output
This will produce the following output −
String1 = 50 String2 = 100 System reference of String1 = 50
Advertisements