What's the size of this C# struct?

what'd
what does
how to pronounce what
what's
what w
what is love
whats the meaning of
what c

Is it 12 bytes or 16 bytes when stored in a List<DataPoint>?

public struct DataPoint
{
    DateTime time_utc;
    float value;
}

Is there any sizeof function in C#?

Take a look at @Hans Passant's answer here for interesting background on this issue, esp. with regard to the limitations of Marshal.Sizeof.

What, a punishment or reprimand (esp in the phrase give (a person) what for) See full dictionary entry for what. Quickly send and receive WhatsApp messages right from your computer.

Marshal.SizeOf()

http://msdn.microsoft.com/en-us/library/y3ybkfb3.aspx

What for definition and meaning, what as a pronoun, it can be the subject, object, or complement of a verb. It can also be the object of a preposition. what definition: 1. used to ask for information about people or things: 2. used in questions that show you are…. Learn more.

What, what also have various functions. It can be used as a adjective, an adverb, a pronoun, or an interjection. noun the true nature or identity of something, or the sum of its characteristics: a lecture on the whats and hows of crop rotation.

It will be 12 bytes (4 for float, 8 for DateTime); Marshal.SizeOf will return 16 because the default packing is 8 bytes aligned. This is a good article on structs and packing. It gives a full description of whats actually happening.

What Part of Speech is “WHAT”, I will do what I can to help you. TranslationsEdit. show ▽what? (interrogative pronoun)  whatever: adverb at all , of any description , of any kind or sort , whatsoever , whichever

Try Marshal.SizeOf(typeof(DataPoint))

What's dictionary definition, what definition: 1. used to ask for information about people or things: 2. used in questions that show you are…. Learn more. From Middle English what, from Old English hwæt (“what”), from Proto-Germanic *hwat (“what”), from Proto-Indo-European *kʷód (“what”), neuter form of *kʷós (“who”).

what, Your questions answered on what type of mask to wear to cut the risk of getting Covid-19. what definition: The definition of what is which one or as many as. (adjective) An example of what used as an adjective is in the sentence, "What shirt do you want?"

WHAT, Usage Note: When what is the subject of a clause, it takes a singular verb if the word or phrase that completes the sentence (the complement) is singular, as in I​  WhatsApp Messenger: More than 2 billion people in over 180 countries use WhatsApp to stay in touch with friends and family, anytime and anywhere. WhatsApp is free and offers simple, secure, reliable messaging and calling, available on phones all over the world.

Coronavirus: what kind of face mask gives the best protection , what definition: The definition of what is which one or as many as. (adjective) An example of what used as an adjective is in the sentence, "What shirt do you  What Is My IP? WhatIsMyIP.com® is the industry leader in providing REAL IP address information. We provide IP address tools that allow users to perform an Internet Speed Test, IP address lookup, proxy detection, IP Whois Lookup, and more.

Comments
  • I hope you are aware that each instance of this struct will be boxed when put in a list, so add the space for the pointer.
  • @ToxicAvenger: it will not be boxed when you put it inside a List<DataPoint>. It would be boxed in an ArrayList or List<object> though.
  • This is more specific, but possibly a duplicate of stackoverflow.com/questions/3361986/…
  • You could add the solution to his question: 16 bytes (8 bytes + 4 bytes + 4 bytes alignment)
  • Marshal.SizeOf() does not return the size of a managed struct, only the unmanaged version of it. Check Steve's answer.
  • Note it's possible with the IL sizeof instruction to get the "final" CLR size of a struct, taking into account padding and any other alignment operations. See my blog post for how to use it and more differences (note: I wrote a wrapper library that can be called from C#)