码迷,mamicode.com
首页 > 其他好文 > 详细

c# 中Intern的作用

时间:2014-07-03 22:11:06      阅读:268      评论:0      收藏:0      [点我收藏+]

标签:blog   io   new   div   har   c#   

1. 函数如下

public static string Intern(string str)
{
      if(str == null)
      {
            throw new ArgumentNullException("str");
      } 
      return Thread.GetDomain().GetOrInterString(str);       
}  

2. 举例说明

   string s1 = "name";

   string s2 = "name";

上述函数的作用就是确保s1,s2指向同一块内存。

c# 中Intern的作用,布布扣,bubuko.com

c# 中Intern的作用

标签:blog   io   new   div   har   c#   

原文地址:http://www.cnblogs.com/seanbrucexxl/p/3820980.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!