当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > Creating GUIDs in c#

ASP.NET
ASP.NET实现数据图表a
ASP.NET实现数据图表1
Kbuilder.cs GIVE ME K
WebForm1.aspx K LINE YISHI GIEVE ME
ASP.NET实现数据图表b
today study 2005.03.03
ActiveX 组件复习笔记.1
Direct3D学习笔记(二)我们这里可以编写一个完全意义上的Direct3D程序了。
HttpContext类包含了个别HTTP请求的所有特定HTTP信息。
实现自定义分页(如:改变传统datagrid的分页显示、通过A-Z的字母来分页等)、选择...
关于Format字符串和Xml文件的解析(粗略)
wrox asp.net 2 beta preview study section 3
整合重复代码,生成自定义的列(组件)整合重复代码,生成自定义的datagrid(组件...
递归法提升密码穷举算法性能
如何用UltraEdit编译C#源程序
添加删除、更新按钮的提示确认信息,以及DATAGRID的添加、插入、更新、删除操作。
WebBrowser应用
My Composite in C#
DBForm的设计来源以及主要构想
.net中交易处理的解决方案

ASP.NET 中的 Creating GUIDs in c#


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

What is a GUID
For those of you who don''t know, a GUID (pronounced goo''id - Globally unique identifier) is a 128-bit integer that can be used to uniquely identify something. You may store users or products in your database and you want somehow uniquely identify each row in the database. A common approach is to create a autoincrementing integer, another way would be to create a GUID for your products.
How to create a GUID in C#
The GUID method can be found in the System namespace. The GUID method System.Guid.NewGuid() initializes a new instance of the GUID class.
There are also a few overloads available for those of you who want the GUID formatted in a particular fashion.
The following live sample will output the GUID generated, the source code is also below.
Response.Write(@"
System.Guid.NewGuid().ToString() = " + System.Guid.NewGuid().ToString());
Response.Write(@"

System.Guid.NewGuid().ToString(""N"") = " + System.Guid.NewGuid().ToString("N"));
Response.Write(@"
System.Guid.NewGuid().ToString(""D"") = " + System.Guid.NewGuid().ToString("D"));
Response.Write(@"
System.Guid.NewGuid().ToString(""B"") = " + System.Guid.NewGuid().ToString("B"));
Response.Write(@"
System.Guid.NewGuid().ToString(""P"") = " + System.Guid.NewGuid().ToString("P"));