How to generate (via button) file properties (randomly) in textboxes fields (screen)

What you need to generate

[assembly: AssemblyTitle("[TITLE]")] [assembly: AssemblyDescription("[DESCRIPTION]")] [assembly: AssemblyCopyright("[COPYRIGHT]")] [assembly: AssemblyVersion("[VERSION]")] [assembly: AssemblyFileVersion("[FILE-VERSION]")] [assembly: AssemblyCompany("[COMPANY]")] [assembly: AssemblyProduct("[PRODUCT]")] 

In general, the essence of what you need when you click on the button to generate different AssemblyText [TEXT] in the textbox in random order!

  • Write these lines to the array or List<string> and shuffle them based on a randomly selected index, and then display them in the text box. - Bulson
  • Can you give an example? - GooliveR

1 answer 1

 private static Random rng = new Random(); public static void Shuffle<T>(this IList<T> list) { int n = list.Count; while (n > 1) { n--; int k = rng.Next(n + 1); T value = list[k]; list[k] = list[n]; list[n] = value; } } 

Usage (insert in button click handler)

 List<string> myStrings = new List<string>(); myStrings.Add(@"[assembly: AssemblyTitle("[TITLE]")]"); //аналогично др.строками набъете myStrings.Shuffle(); //перетасовываем StringBuilder builder = new StringBuilder(); foreach(var item in myStrings) { builder.Append(item); builder.Append(" "); } this.MyTextBox.Text = builder.ToString(); 
  • Do not tell me how to generate this line? string [] sv = {"Windows", "Microsoft", "ZoooFMega"}; - GooliveR
  • @ArteS did not understand the question. - Bulson
  • Thanks for the example above, I want to know whether it is possible to call the text from string [] sv ?? This is how it will be clearer, I think) - GooliveR
  • According to your example above, I use all this in UserControl, I get an error: Error 1 The extension method must be defined in a static class that is not universal - GooliveR
  • Is it possible to add your example to the class and call it from there already? - GooliveR