鸟食轩

 Microsoft .NET[C#] MVP 2003
随笔 - 424, 文章 - 231, 评论 - 5394, 引用 - 344
数据加载中……

简单名称值对节点类NameValuePair

    本类位于System.Data.dll中,名为:System.Data.Common.NameValuePair。主要用途是在DBConnectionString类中,解析ConnectionString时存储并串联Name/Value对。框架类中没有使用Collection名称空间下的通用集合类,应该是出于效率和便于持久化方面的考虑。

[Serializable]
public sealed class NameValuePair
{
    
private readonly string _name;
    
private NameValuePair _next;
    
private readonly string _value;

    
public NameValuePair(string name, string value)
    
{
        
if ( StringHelper.IsEmpty(name) )
        
{
            
throw new ArgumentException("name");
        }

        
this._name = name;
        
this._value = value;
    }


    
public NameValuePair(string name, string value, NameValuePair next) : this(name, value)
    
{
        
this._next = next;
    }


    
public NameValuePair Clone()
    
{
        
return new NameValuePair(this._name, this._value);
    }


    
public string Name
    
{
        
get return this._name; }
    }


    
public NameValuePair Next
    
{
        
get
        
{
            
return this._next;
        }

        
set
        
{
            
if ( this._next != null )
            
{
                
throw new InvalidOperationException();
            }

            
this._next = value;
        }

    }


    
public string Value
    
{
        
get
        
{
            
return this._value;
        }

    }

}

posted on 2005-05-15 02:47 birdshome 阅读(965) 评论(2)  编辑 收藏 所属分类: .NET的私有工具类

评论

#1楼    回复  引用  查看    

这个性能怎么样?
2005-09-08 14:36 | selina      

#2楼    回复  引用    

一点点用
2007-03-24 21:57 | Primemens [未注册用户]

标题  
姓名  
主页
Email (只有博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2005-07-17 18:14 编辑过