본문 바로가기
개발언어/C#.NET

C# GUID 만들기

by 엔돌슨 2011. 4. 13.
반응형

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.


GUID 사용하기


GUID를 생성하여 사용할 수 있습니다. 파일전송시 유일한 키가 필요할때 생성하여 사용하였습니다. 아마 중복되지 않는 유일한 키일겁니다.
System.Guid.NewGuid().ToString()

GUID가 무엇인지 알아야 한다.
http://ko.wikipedia.org/wiki/%EC%A0%84%EC%97%AD_%EA%B3%A0%EC%9C%A0_%EC%8B%9D%EB%B3%84%EC%9E%90
백과사전을 보면 전역 고유 식별자(Globally Unique Identifier, GUID)라고 나와 있습니다.


참고사이트
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=335