当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > GUID在.net里的使用,就用System.Guid结构

ASP.NET
Asp.Net 通用数据操作类 (附通用数据基类)
asp.net汉字转拼音和获取汉字首字母的代码
asp.net 多字段模糊查询代码
OpenCms 带分页的新闻列表
URLRewriter最简单入门介绍 URLRewriter相关资源
asp.net Repeater取得CheckBox选中的某行某个值
asp.net清空Cookie的两种方法
asp.net一些很酷很实用的.Net技巧
asp.net生成高质量缩略图通用函数(c#代码),支持多种生成方式
asp.net TripleDES加密、解密算法
Asp.net中防止用户多次登录的方法
asp.net Repeater取得CheckBox选中的某行某个值的c#写法
asp.net DataGridView导出到Excel的三个方法[亲测]
C#,winform,ShowDialog,子窗体向父窗体传值
asp.net学习中发现的比较完整的流程
ASP.net 页面被关闭后,服务器端是否仍然执行中?
asp.net Context.Handler 页面间传值方法
asp.net xml序列化与反序列化
asp.net实例代码protected override void Render(HtmlTextWriter writer)
asp.net(c#)捕捉搜索引擎蜘蛛和机器人

ASP.NET 中的 GUID在.net里的使用,就用System.Guid结构


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 224 ::
收藏到网摘: n/a

NewGuid静态/分享方法
==运算符
!=运算符

using System;

namespace PlayGUID
{
    /// <summary>
    /// Class1 的摘要说明。
    /// </summary>
    class Class1
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            //使用NewGuid静态方法,得到一个guid的新实例
            System.Guid guid = System.Guid.NewGuid();
            System.Console.WriteLine(guid.ToString());

            //
            // 相等运算符和不等运算符是Guid结构自己的运算符,不要和运算符"=="、"!="弄混
            //

            System.Guid guid2 = guid;
            if(guid == guid2)//使用相等运算符判断两个guid是否相等
            {
                System.Console.WriteLine(guid.ToString() + "等于" + guid2.ToString());
            }

            guid2 = System.Guid.NewGuid();
            if(guid != guid2)//使用相等运算符判断两个guid是否不等
            {
                System.Console.WriteLine(guid.ToString() + "不等于" + guid2.ToString());
            }

            System.Console.ReadLine();
        }
    }
}