[Solved] This c# code displays the first letter decimal value of a string only…e.g the output is ..101.. when it should display … 101 032 057 097 065 [closed]


Declare a string value and append to it on each iteration, then set the textbox.text property value.

     using System;
     using System.Collections.Generic;
     using System.Drawing;
     using System.Windows.Forms;
     using System.IO; 

     namespace encrypto
     {
       public partial class MainForm : Form
       {
         public MainForm()
         {

            InitializeComponent();

         }

    void OnClick(object sender, EventArgs e)
    {
        string  Plaintext = textBox1.Text;
        string byteText = "";
        byte CipherText;
        if (String.IsNullOrEmpty(textBox1.Text)) 
        {
            MessageBox.Show("Please Enter Text To Be Hidden.", "Error", 
            MessageBoxButtons.OK,    MessageBoxIcon.Warning);

        }

        for(int i=0; i < Plaintext.Length;i++)
        {
           CipherText = (byte)Plaintext[i];
           byteText += System.Convert.ToString(CipherText) + " ";     //+= appends text to the string          
        }
           textBox3.Text = string.Format ("{0}",byteText);    //Now that we have all byte text in our string, place it into the textbox.Text property as value
    }

4

solved This c# code displays the first letter decimal value of a string only…e.g the output is ..101.. when it should display … 101 032 057 097 065 [closed]