如何在C#中检索系统对指定String的引用?
要检索系统对指定String的引用,代码如下-
示例
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);
}
}输出结果
这将产生以下输出-
String1 = David System reference of String1 = David
示例
现在让我们来看另一个示例-
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);
}
}输出结果
这将产生以下输出-
String1 = 50 String2 = 100 System reference of String1 = 50
热门推荐
1 如何训练狗狗握手
10 新员工寄语祝福语简短
11 新婚敬酒祝福语大全简短
12 怎么训练狗狗
13 训练狗狗上厕所
14 春蚕老师祝福语简短励志
15 高考好运如愿祝福语简短
16 战哥过年祝福语简短
17 中考感谢朋友祝福语简短
18 长沙旅游祝福语大全简短