How to generate a Uniq Number C#
<p>I want to generate a Uniq Number something like TMP-0001354, TMP will be always same only number will get change, which should not be get duplicate in table.</p>

<p>I want to a exp. code which should be in c#, I'll call that function at the time of inserting the record in table. SQL server database I am using</p>

<p>I am trying this I don't know will it work fine or not.</p>

<pre><code> private string RandomNumberGenerator()
    {
        int maxSize = 8;
        int minSize = 5;
        char[] chars = new char[62];
        string a;
        a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
        chars = a.ToCharArray();
        int size = maxSize;
        byte[] data = new byte[1];
        RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider();
        crypto.GetNonZeroBytes(data);
        size = maxSize;
        data = new byte[size];
        crypto.GetNonZeroBytes(data);
        StringBuilder result = new StringBuilder(size);
        foreach (byte b in data)
        { result.Append(chars[b % (chars.Length - 1)]); }
        return result.ToString();
    }
</code></pre>

<p>Some one please help me.</p>
