how to copy from text box to struct C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajithbayya
    New Member
    • Oct 2010
    • 1

    #1

    how to copy from text box to struct C#

    I need to copy the strings from text box to struct. is there any way to do it? here's what am trying:
    Code:
    public unsafe struct mystruc
    {
        public byte[] install_name; // size limit 32 bytes
        public byte[] install_id;   // size limit 4 bytes
        public byte[] model_name;   // size limit 4 bytes
    };
    
    private void read_b_Click(object sender, EventArgs e)
    {
        mystruc mstruc1 = new mystruc();
    
        //copy from textbox to struct    
        mstruc.install_name = Encoding.UTF8.GetBytes(installation_name_tb.Text);
        mstruc.install_id = Encoding.UTF8.GetBytes(installation_id_tb.Text);
        mstruc.model_name = Encoding.UTF8.GetBytes(model_tb.Text);    
    }
    and also other way round. its not working.. :( any help greatly appreciated
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    Note, I reported the other one, you got a duplicate post. Lets keep this one :)

    Comment

    • GaryTexmo
      Recognized Expert Top Contributor
      • Jul 2009
      • 1501

      #3
      Can you describe how it's not working? I just plugged your code in and does indeed work for me. Please be a bit more descriptive in what the problem is, and the result you're looking for.

      Thanks!

      Comment

      Working...