Загрузка...

Help with cysel generator in C#

Thread in C# created by Quintin_inactive5175316 Apr 26, 2022. 317 views

  1. Quintin_inactive5175316
    Quintin_inactive5175316 Topic starter Apr 26, 2022 Banned 268 Mar 27, 2022
    [IMG]
    Есть вот такая виндовс форма
    В которой при нажатии на кнопку1
    будет выводиться рандомно сгенерированный 8 значный код от 0-9
    В текст бок 1
    Буду очень благодарен если скинут готовый код ♥
     
  2. Q_Q
    Q_Q Apr 26, 2022 225 Apr 22, 2022
    Random rnd = new Random();
    int month = rnd.Next(1, 13); // creates a number between 1 and 12
    int dice = rnd.Next(1, 7); // creates a number between 1 and 6
    int card = rnd.Next(52); // creates a number between 0 and 51
     
    1. View previous comments (4)
    2. Quintin_inactive5175316 Topic starter
      Q_Q, из за команды Rnd
    3. Q_Q
      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Drawing;
      using System.Linq;
      using System.Text;
      using System.Windows.Forms;

      namespace CAT_2
      {
      public partial class Form1 : Form
      {
      public Form1()
      {
      InitializeComponent();
      this.Load+=new EventHandler(Form1_Load);
      button1.Click+=new EventHandler(button1_Click);
      }
      void Form1_Load(object sender, EventArgs e)
      {
      button1.Text = "Start";
      }
      void button1_Click(object sender, EventArgs e)
      {
      Random rand = new Random();
      int i = rand.Next(-100, 9);
      if (i > 0)
      listBox1.Items.Add(i).ToString();
      else
      listBox2.Items.Add(i).ToString();
      }
      }
      }
    4. vtlstolyarov
      Quintin_inactive5175316, Пиздеж, класс Random вообще не менялся между фрэймворками
  3. Quintin_inactive5175316
    Quintin_inactive5175316 Topic starter Apr 26, 2022 Banned 268 Mar 27, 2022
    А забыл добавить на 4 фрэйме должно быть
     
  4. r1soX
    r1soX Apr 28, 2022 231 Oct 14, 2017
    C#
    private static Random random = new Random();

    public static string RandomString(int length) //Где length - это длина пароля
    {
    const string chars = "0123456789"; //Сюда можно вставлять любые буквы, символы, знаки и т.д
    return new string(Enumerable.Repeat(chars, length)
    .Select(s => s[random.Next(s.Length)]).ToArray());
    }
     
Top
Loading...