Why is the BinaryFormatter output's size so high

Hi there,
given this example:
class Program
void Main(string[] args)
myFoo = new foo(string.Empty,
string.Empty);
BinaryFormatter bf = new BinaryFormatter();
MemoryStream memstream =new MemoryStream();
bf.Serialize(memstream, myFoo);
byte[] bytes = memstream.ToArray();
Console.WriteLine(bytes.Length.ToString());
Console.ReadKey();
[Serializable]
class foo
private string foo1;
private string foo2;
public foo(string s1, string s2)
foo1 = s1;
foo2 = s2;
Why do I get an Arrylength of 142 bytes although I am serializing a simple class with two empty strings. And wouldn´t it be much more efficient to write my own serializer with Encoding.ASCII.GetBytes , etc...
Thank you for your answers
 

Ok, I think I expressed myself in a wrong way. I didn´t consider my approach to serialise an object to be more efficient than the BinaryFormatter class. But the resulting byte package is much more smaller in my approach in terms of size. So when I use encoding.ASCII
I get 1 byte for every character of the strings. Wouldn´t that be better in case I have to send this package over a network for example. Of course I have to make sure that there are some kinds of seperators between the strings and I have to provide a deserialise
and serialise methode on both sides. Please correct me if I am wrong.
But anyways thank you for your answer

Similar Messages

  • Why are the video player change size when resizing the window a little?

    When I use the video player to show mp4 files, the "player window" changes size if I change the firefox window. Why and how do I do to get the correct size direct (640x480)

    Hi john3,
    This can be the resolution of the screen or the site detecting screensize, do you have a url we can take a look at to determine what's going on?
    Thank you!

  • Why is the volume changer button up so high on the new apple headphones?

    On the newest Apple Headphones, I was wondering why the headphones volume changer button so high. It is difficult to try to change the volume when listening to music because i cant see the volume changer button.

    I assume that you did not check before buying, if you had you would have seen that your Mac is too old for Airplay Mirroring to work:
    Supported Macs
    AirPlay Mirroring in OS X Mountain Lion takes advantage of the hardware video encoding capabilities of 2nd and 3rd Generation Intel Core processors. Hardware video encoding allows AirPlay Mirroring to efficiently deliver high frame rates while maintaining optimal system performance. The following Mac models have processors that support AirPlay Mirroring:
    iMac (Mid 2011 or newer)
    Mac mini (Mid 2011 or newer)
    MacBook Air (Mid 2011 or newer)
    MacBook Pro (Early 2011 or newer)
    And if you bought ML solely for that function you should remove it from your machine and get a refund.

  • Why is the DAQ outputs distorted?

    I am trying to output two voltage sine waves(90 degrees out of phase) from my DAQ card. I use a for loop to create two arrays of 1000 samples each. I then send each of these arrays to my DAQ card for sampling of 5000S/s. One of the outputs(measured on an oscilliscope is perfect while the other clips and is distorted. Why am i not getting twp perfectly good sign waves?Is this a hardware issue?
    Please find attached my LabView file.
    Thanks,
    Gilly
    Attachments:
    Sine_forloop_nearlydone.vi ‏91 KB

    I haven't looked at your vi yet, don't have 8.6 on this machine (please identify the version when attaching vi's), but do have some questions. Are they both set to the same amplitude? Are you looking at them individually (re: single channel scope) or both channels at the same time? Are they both connected to the DAQ inputs in the same way. Usually, if there isn't an actual hardware problem with the outputs, distortion and clipping are caused by; 1) trying to output a waveform of an amplitude greater than allowed, 2) trying to drive a seriously mismatched load. In the later category hooking up to the DAQ incorrectly might cause a problem.
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

  • Why is the print output including spaces between every letter?

    All printed output has spaces between each letter. Example:
    A l l p r i n t e d o u t p u t h a s s p a c e s b e t w e e n e a c h l e t t e r .

    Caused by a Bug in 4.0b12, Was fixed in the 02-28 nightly, and the fix will be in the 4.0RC version due to be released next week.

  • Why is the headphones output jack so loud?

    The output from the headphone jack on the left of my MacBook Pro 15" (base model, latest as of 16/07/11) is incredibly loud. Even when my Mac has the volume on one 'bar' or 'block' when using the volume buttons, it's still extremely loud and almost deafening. I fear how loud it must be over two blocks, because I simply can't listen to it.
    Is there any change the min/max volumes that are possible? This MacBook Pro is only 2 days old.

    blakei21 wrote:
    Changing the output volume in Settings yeilds the same result, still very loud. I also performed a PRAM reset and it's still very loud.. this is a really weird problem :\
    Hmmm. Agreed, very weird. There have been many and varied issues with MBP audio out ports. I would try another set of headphones, if possible, and if same issue there, contact Apple. 90 days free phone support, 1 year hardware warranty, 14 day return/exchange period.

  • Why has the text and general size of page suddenly shrunk in size in websites and especially in retrieved email sites? Every retrieved page needs to be zoomed in on.

    Without explanation every retrieved email site or online website appears on screen in minute font and picture size and needs to be zoomed in on to allow normal visibility.

    Reset the page zoom on pages that cause problems: <b>View > Zoom > Reset</b> (Ctrl+0 (zero); Cmd+0 on Mac)
    * http://kb.mozillazine.org/Zoom_text_of_web_pages

  • HT3986 Why does the sound output not work on Windows 7 Bootcamp?

    The internal speakers work fine, but I want to use my surround sound and can't seem to get it to work. It doesn't even work with headphones. Is there an update I need to install or what?

    Alll I can offer is what I bookmarked, that you can access, other threads, and of course Google and what others have found works.
    A simple instruction manual I can't offer but a few words of wisdom, Apple provides driver to enable a chip or device but that is not the end, just the beginning.
    "Cirrus+audio+iMac+Windows"

  • Why is the price of my Iphone 5s higher than the official price? I bought a 16G balck Iphone 5s in America Airport recently, and it costed me $850. I wondered are there any differences between mine and the ones sold on the apple online store?

    Recently, my friend bought me a 16G black Iphone 5s at America airport and it costed $850.
    But I really hope to know why it cost $201 more than the ones that sold on apple online store, since the consumption tax can't be that much.
    Really hope to get some help.

    Hi, beth.lau.gr.
    Thank you for visiting Apple Support Communities.  
    I understand you have been experiencing issues with your iPhone restarting and showing you a blue screen.  I wont be able to give you an exact answer as to why this is happening.  However, this is the most relevant troubleshooting article for this issue.  This article also provides options to reach out to us via phone for additional assistance.  
    If your iOS device restarts, displays the Apple logo, or powers off while you're using it
    http://support.apple.com/en-us/HT203899
    Cheers, 
    Jason H.  

  • Why is the price of iphone 4s so high in India?

    We have to pay 80,000 to 90,000 rs. or $1800 roughly for the 16gb version. We love apple products and want to buy them but at this price it is impossible for us to buy.

    I don't know where you're getting your pricing, but I'm looking at the Aircel web page right now and they show a price of 34,500 for the iPhone 4.  That's roughly US$693. Not too far off for what it cost for an unlocked iPhone 4 in the US prior to the release of the 4S. My guess is that the 4S hasn't been released in India yet, and the prices you're seeing are for gray market phones brought in from other regions.
    Why don't you just wait for the official release or ask either Aircel or airtel how much it is. There are NO other authorized sources for iPhones in India.

  • Why is the number of earlier visits so high in the security tab of the certificate information window when visiting a https protected site(in my case 13.400) even after deleting cookies?

    When you go to www.gmail.com and I rightclick on the gray coloured "google.com" showed left next to the address bar then it shows you the certification details. Whe you click on "more info" and then go to the security section it show you how many times you visted the site before. In my case it say`s none, but thats not the case with my friend, his nuber of earlier visits says 13.400 even after deleting cookies/history.
    Can someone tell me what this means, and if maybe someone other than himself is watching his email because he`s a bit worried now.

    A possible cause is a problem with the file places.sqlite that stores the bookmarks and the history.
    *http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    *https://support.mozilla.com/kb/Bookmarks+not+saved#w_places-database-file

  • In my Macbook Pro finder folder under All Images, there are duplicate files, but one is small and the other is full size. I wanted to clean up the files, but don't know why I have two of everything. Any Ideas?

    In my Macbook Pro, the Finder folder has duplicate images in the 'all images' file. One image is small and the other is full size. First question is why do I have two of every image? Why is one small and the other large. Do I need two of everything? If not, which do I delete?
    thanks, Jean

    Hello fane,
    Re: duplicate images in finder.
    Nearly all images are JPG with a few GIF and PNG sprinkled in.
    I opened the inspector so I do get info when opening each image, but it a slow process.
    It seems that one image is around 70k while its twin can be up to 4Mb which is what comes unedited from my camera. Sometimes there will be 3 or 4 identical images in finder, but when I open iPhoto to see what ‘s really in the file, I find only one image, and it’s full sized.
    Are all these extra images, even if they are aliases, taking up space on my drive? And should I delete them? The info bar says I have over 10,000 images, which is rather a lot  for what I do.
    I am unable to add the file size on the view menu as it is grayed out. Don’t know why it’s gray, but having that info on the screen would save a lot of time and fiddling with each image.
    I am trying to resize selected pix so I can upload them to e-bay, which requires less than 70k. I have looked at resizing programs but most are for PC platform and not Mac, so I am trying to resize in the finder window under tools. Tedious at best. Any suggestions will be appreciated
    Thanks for your help,
    jeanfromwilsonville

  • Why is the body area of my site a different size in the preview view than than in the design view?

    Why is the body area of my site a different size in the preview view than than in the design view?

    Why is the body area of my site a different size in the preview view than than in the design view?

  • Why is the character style for hyperlinks not displaying correctly in design mode/viewing/output?

    I am using RH9 and generating WebHelp, and I needed to globally bump up the font size of just my hyperlinked text. I went into my Style Sheet > Character tab, changed the font size of the various character settings for hyperlinks, and clicked Apply and then OK. Normally, this would change all of my hyperlink text font sizes immediately across all of my topics. However, this time, it made no changes to any existing hyperlinked text, and it only affected new hyperlinks that I subsequently added. For the existing hyperlinks, I can only manually change the font size of the each hyperlink one at a time, but that's crazy (there's 100's in this help).
    I can successfully change other characters styles and paragraph styles. This issue only affects the hyperlink character styles. It also shows up in all RH modes - Design mode, viewing, and in the final output.
    Is this an indication of a corrupted style sheet or some other combination of events that I have yet to discover?

    Hi,
    You probably have inline styling in your project overwriting the font size of your style sheet. How are you changing the font size of the individual hyperlinks?
    There is a workaround for inline styling: Open your CSS in notepad and add !important after the font-size:
    font-size: 4pt !important;
    Note that this is a workaround, not a solution. As a solutions you can remove all the style attributes from your hyperlinks to force them to take the CSS styling again.
    Greet,
    Willam

  • Why is the size of my FPGA VI increasing?

    I am using LABview 8.5 FPGA Module.  I noticed that the size ov my FPGA VI file keeps increasing when it shouldn't.  As a test, I added one simple control to my FPGA VI file and saved it.  As expected, the size of the file increased.  I then went in and did nothing more than delete this control I just added, then saved the file.  The size of the file INCREASED again!  Why would it increase when I delete something from the file!?
    Anyone else see this happen?  Is there some Labview option I need to set or un set to stop this??
    Thanks,
    Rick

    Thanks for your interest, Wiebe.
    The history is off as far as I know. I think the slices are the same.  As amatter of fact, one experiment I did was I checked the VI Properties->Memory Usage, added a simple control, saved the VI, deleted the control, saved it, and looked at the Properties->Memory Usage again.  The numbers between the two times I checked the Memory Usage were the same EXCEPT for the "Total VI Size On Disk", which had increased.
    Here's a detailed description of something I did yesterday.  My FPGA VI had grown to a 140Meg.  I know, pretty big.  I do have a lot in it because of what my application demands.  I created a new empty VI and painstakingly copied all the Labview code (eg. front panel items, block diagrams, etc) from the 140Meg VI to this new one.  I saved the new one.  Bottom line hey had the axact same "code".  However, the new VI file size was only 20Meg!
    I'm beginning to believe that the Save command stored previous versions of my Labview code within the VI file, perhaps for purposes of being able to revert to older revisions???  I know I grasping at straws, but this is becoming an issue.  Any NI engineer listening that knows about this.

Maybe you are looking for

  • Error in Module Development

    Hi Experts, I am getting the below error while I am trying to test the Scenario having custom module to read Excel file In the ejb-j2ee-engine.xml I have given  JNDI name readExcel In the Sender Communication channel I have specified readExcel In the

  • [newbie] xorg, intel, I830WaitLpRing() error?

    Folks; first off, being rather new to archlinux, let me say I am pretty impressed with what I see after getting the system up and running. Been into Linux for quite a bunch of years by now, having dealt with Xubuntu as of recently and am looking for

  • OVM Template Import

    Hello! I have such question. Does the VM template stored in the repository wholly? Or in repository stored only the link on the template? Thanks

  • Where can i see the final print preview for a rfq document./ ??

    Hello, where can i see the final print preview for a rfq document./ ??

  • How to open oracle vm manager???????

    How to open oracle vm manager in oracle vm server ?????? need GUI to creat guest O/S?????? Help.... Thank you