Appends the string with some random guid. - CSharp System

CSharp examples for System:Random

Description

Appends the string with some random guid.

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Security.Cryptography;
using System.Numerics;
using System.Linq;
using System.Globalization;
using System.Collections.Generic;
using System;/*from w  w  w  .  j a  v  a  2 s  . c o m*/

public class Main{
        /// <summary>
        /// Appends the string with some random guid.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns></returns>
        public static string AppendRandom(this string input)
        {
            return input + "_" + Guid.NewGuid()
                                     .ToString("N")
                                     .Substring(28, 4)
                                     .ToLowerInvariant();
        }
}

Related Tutorials