Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to pass an explicit array of bytes as a byte array

Posted on 2011-09-04
1
Medium Priority
?
314 Views
Last Modified: 2012-05-12
I have a method that accepts a byte array as a parameter:
    private void mymsg(byte[] barray)
    {
      ...
    }

Open in new window

which I currently call:
      byte[] n = { 0x35, 0x04 };
      mymsg( n );

Open in new window

I'd like to call it in one step instead of two. Something like this (but without the syntax errors)
   mymsg( { 0x35, 0x04 } );

Open in new window

What's the proper syntax for this?
0
Comment
Question by:deleyd
1 Comment
 
LVL 17

Accepted Solution

by:
andrewssd3 earned 2000 total points
ID: 36481323
I think the syntax you're looking for is

mymsg(new byte[]{ 0x35, 0x04 });

Open in new window


although I'm not sure it makes much difference, except saving a line!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question