Answer the question
In order to leave comments, you need to log in
C# WindowsForm how to display elements from an array in a TextBox without repeating?
^', '&', '(', ')'} in winform there are two TextBoxes, and in the first one, the user enters the number of characters to be displayed in the second TextBox, in the second, random characters from the array are displayed accordingly.
For example: If you enter the number 4 in the first TextBox, 4 elements will be displayed (for example, "jx
Also in the first TextBox-e there is a restriction that you cannot enter anything other than positive numbers and the number cannot be more than 60 (otherwise an error is displayed).
You need to write a code that in the TextBox second, when you click on the generate button, displays the elements of the array without repetition (for example, it should not be shown twice n, or twice 1, etc.)
Answer the question
In order to leave comments, you need to log in
char[] m = default;
// что означает вообще null
// где то чем то заполняем m
var m2 = m.Distinct();
// m2 будет иметь тип IEnumerable<char> и содержать только уникальные элементы
// если нужен массив, тогда так
var m2 = m.Distinct().ToArray();
// если нужен лист, тогда так
var m2 = m.Distinct().ToList();
// исходный m тоже может быть и List и IEnumerable, будет работать для любого варианта
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question