첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170
using System;
using System.Text;

#region 임의(Random) ID 구하기 - GetRandomID(int idLength = 8)

/// <summary>
/// 임의(Random) ID 구하기
/// </summary>
/// <param name="idLength">ID 길이</param>
/// <returns>임의(Random) ID</returns>
public string GetRandomID(int idLength = 8)
{
    string characterList      = "abcdefghijkmnopqrstuvwxyz1234567890";
    int    characterListCount = characterList.Length;

    StringBuilder stringBuilder = new StringBuilder(idLength);

    int count = 0;

    foreach(byte value in Guid.NewGuid().ToByteArray())
    {
        stringBuilder.Append(characterList[value % (characterListCount - 1)]);

        count++;

        if(count >= idLength)
        {
            return stringBuilder.ToString();
        }
    }

    return stringBuilder.ToString();
}

#endregion
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요