Correct Way to Add byte Variables into byte Arrays


What I am trying to do is get input from the user and store it in a byte array. Please note, I must store var1 variable in a byte array and not a list.

Console.Write("Enter a number: "); byte var1 = byte.Parse(Console.ReadLine()); byte[] byteArray = new byte[] {}; byteArray[0] = var1;


Arrays are fixed in size, you must specifiy the size of the array when you create it. In your example you told it to make an array of size 0 by putting the {} after the byte[]. Instead remove the {} and just put a 1 between the []

Console.Write("Enter a number: "); byte var1 = byte.Parse(Console.ReadLine()); byte[] byteArray = new byte[1]; byteArray[0] = var1;


  • getopts no argument provided
  • Z3 int2bv operation
  • several hexbin plots on one PDF page in R
  • Create JSON Request string using Javascript Overlay types in GWT
  • (Tcl/Expect) clear screen after exit
  • Scanner nextInt() and hasNextInt() problems
  • jQuery: How to AJAXify WordPress Search?
  • Trying to get the char code of ENTER key
  • MongoDB in PHP using aggregate to group by _id is null not working
  • Email format validation in mvc3 view
  • How do I change content of ComboFieldEditor?
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • C# - Is there a limit to the size of an httpWebRequest stream?
  • How to add date and time under each post in guestbook in google app engine
  • Validaiting emails with Net.Mail MailAddress
  • Which linear programming package should I use for high numbers of constraints and “warm starts” [clo
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Javascript + PHP Encryption with pidCrypt
  • what is the difference between the asp.net mvc application and asp.net web application
  • Upload files with Ajax and Jquery
  • Weird JavaScript statement, what does it mean?
  • How do you troubleshoot character encoding problems?
  • Do I've to free mysql result after storing it?
  • How to pass list parameters for each object using Spring MVC?
  • How to format a variable of double type
  • Matrix multiplication with MKL
  • SQL merge duplicate rows and join values that are different
  • Proper way to use connect-multiparty with express.js?
  • coudnt use logback because of log4j
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Turn off referential integrity in Derby? is it possible?
  • Authorize attributes not working in MVC 4
  • Add sale price programmatically to product variations
  • Busy indicator not showing up in wpf window [duplicate]
  • Binding checkboxes to object values in AngularJs
  • How to Embed XSL into XML
  • Unable to use reactive element in my shiny app
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF
  • How do I use LINQ to get all the Items that have a particular SubItem?