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

ASP.NET
asp.net 动态生成表格
asp.net 程序优化精选
DataGridView自动调整行高和行宽
asp.net+js实现的ajax sugguest搜索提示效果
asp.net 将设有过期策略的项添加到缓存中
asp.net SqlDataAdapter对象使用札记
DataGrid 动态添加模板列 实现代码
asp.net 设置GridView的选中行
the sourcesafe database has been locked by the administrator之解决方法
asp.net 退出登陆(解决退出后点击浏览器后退问题仍然可回到页面问题)
Asp.Net HttpHandler 妙用
ASP.NET 保留文件夹详解
asp.net 中将表单提交到另一页 Code-Behind(代码和html在不同的页面)
SqlDataSource 链接Access 数据
asp.net GridView的删除对话框的两种方法
asp.net 按字节检查包含全半角的文字
asp.net String.IsNullOrEmpty 方法
asp.net System.Net.Mail 发送邮件
c# 读取文件内容存放到int数组 array.txt
asp.net Split分割字符串的方法

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 223 ::
收藏到网摘: 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();
        }
    }
}