public String CreateCode() { Random rnd = new Random(); int SiteMovieLen = this.OnSiteMovie.SelectedItem.ToString().Length; int SiteCategoryLen = this.OnSiteCategory.SelectedItem.ToString().Length; int SiteMovieRandom = rnd.Next(0,SiteMovieLen); int SiteCategoryRandom = rnd.Next(0,SiteCategoryLen); string code = this.OnSiteMovie.SelectedItem.ToString().Substring(0,SiteMovieRandom); code += this.OnSiteDay.SelectedIndex.ToString(); code += this.OnSiteNr.SelectedIndex.ToString(); code += this.OnSiteTime.SelectedIndex.ToString(); code += this.OnSiteCategory.SelectedItem.ToString().Substring(0,SiteCategoryRandom); return code; }