Please show in the screenshots how to use this code correctly C#

Иван Святкин 1 Reputation point
2021-04-08T20:01:53.21+00:00

using System;
using System.Windows.Forms;

namespace CB
{
public partial class Form1 : Form
{
private string alf = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя";
public Form1()
{
InitializeComponent();
}

    private void Ecnrypt_Click(object sender, EventArgs e)
    {
        string inp = InputText.Text;
        string outp = string.Empty;
        int value = (int)Number.Value;
        for (int i = 0; i < inp.Length; i++)
        {
            char currs = inp[i];
            int curri = alf.IndexOf(currs);
            int step = curri + value;
            if (step > alf.Length) step %= alf.Length;
            outp += alf[step];
        }
        OutputText.Text = outp;
    }

    private void Decrypt_Click(object sender, EventArgs e)
    {
        string inp = InputText.Text;
        string outp = string.Empty;
        int value = (int)Number.Value;
        for (int i = 0; i < inp.Length; i++)
        {
            char currs = inp[i];
            int curri = alf.IndexOf(currs);
            int step = curri - value;
            if (step < 0) //ToDo
            outp += alf[step];
        }
        OutputText.Text = outp;
    }
}

}

namespace CB
{
partial class Form1
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// Освободить все используемые ресурсы.
    /// </summary>
    /// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region Код, автоматически созданный конструктором форм Windows

    /// <summary>
    /// Требуемый метод для поддержки конструктора — не изменяйте 
    /// содержимое этого метода с помощью редактора кода.
    /// </summary>
    private void InitializeComponent()
    {
        this.InputText = new System.Windows.Forms.RichTextBox();
        this.Number = new System.Windows.Forms.NumericUpDown();
        this.OutputText = new System.Windows.Forms.RichTextBox();
        this.Ecnrypt = new System.Windows.Forms.Button();
        this.Decrypt = new System.Windows.Forms.Button();
        ((System.ComponentModel.ISupportInitialize)(this.Number)).BeginInit();
        this.SuspendLayout();
        // 
        // InputText
        // 
        this.InputText.Location = new System.Drawing.Point(12, 12);
        this.InputText.Name = "InputText";
        this.InputText.Size = new System.Drawing.Size(217, 250);
        this.InputText.TabIndex = 0;
        this.InputText.Text = "";
        // 
        // Number
        // 
        this.Number.Location = new System.Drawing.Point(235, 13);
        this.Number.Name = "Number";
        this.Number.Size = new System.Drawing.Size(150, 26);
        this.Number.TabIndex = 1;
        this.Number.Value = new decimal(new int[] {
        3,
        0,
        0,
        0});
        // 
        // OutputText
        // 
        this.OutputText.Location = new System.Drawing.Point(391, 12);
        this.OutputText.Name = "OutputText";
        this.OutputText.ReadOnly = true;
        this.OutputText.Size = new System.Drawing.Size(217, 250);
        this.OutputText.TabIndex = 2;
        this.OutputText.Text = "";
        // 
        // Ecnrypt
        // 
        this.Ecnrypt.Location = new System.Drawing.Point(235, 45);
        this.Ecnrypt.Name = "Ecnrypt";
        this.Ecnrypt.Size = new System.Drawing.Size(150, 31);
        this.Ecnrypt.TabIndex = 3;
        this.Ecnrypt.Text = "Зашифровать";
        this.Ecnrypt.UseVisualStyleBackColor = true;
        this.Ecnrypt.Click += new System.EventHandler(this.Ecnrypt_Click);
        // 
        // Decrypt
        // 
        this.Decrypt.Location = new System.Drawing.Point(235, 82);
        this.Decrypt.Name = "Decrypt";
        this.Decrypt.Size = new System.Drawing.Size(150, 31);
        this.Decrypt.TabIndex = 4;
        this.Decrypt.Text = "Расшифровать";
        this.Decrypt.UseVisualStyleBackColor = true;
        this.Decrypt.Click += new System.EventHandler(this.Decrypt_Click);
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(621, 282);
        this.Controls.Add(this.Decrypt);
        this.Controls.Add(this.Ecnrypt);
        this.Controls.Add(this.OutputText);
        this.Controls.Add(this.Number);
        this.Controls.Add(this.InputText);
        this.Name = "Form1";
        this.Text = "Form1";
        ((System.ComponentModel.ISupportInitialize)(this.Number)).EndInit();
        this.ResumeLayout(false);

    }

    #endregion

    private System.Windows.Forms.RichTextBox InputText;
    private System.Windows.Forms.NumericUpDown Number;
    private System.Windows.Forms.RichTextBox OutputText;
    private System.Windows.Forms.Button Ecnrypt;
    private System.Windows.Forms.Button Decrypt;
}

}

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,821 questions
{count} votes