Need interpretation of section in C# specification

I am reading the C# specification. I could use clarification on a segment:

C# has a unified type system. All C# types, including primitive types
such as int and double, inherit from a single root object type. Thus,
all types share a set of common operations, and values of any type can
be stored, transported, and operated upon in a consistent manner.
Furthermore, C# supports both user-defined reference types and value
types, allowing dynamic allocation of objects as well as in-line
storage of lightweight structures.

What does “in-line storage of lightweight structures” mean in this context?

Svick’s answer is good but I thought I would add a few extra points.

First off, the paragraph is flawed. Pointer types do not inherit from object. Values that are at compile time known to be interface types or type parameter types will, at runtime, be either invalid references or bona-fide instances of something that inherits from object, but it has always struct me as odd to say that these types “inherit” from object; inheritance is the property that members of the ancestor are members of the descendent, but you don’t normally think of “ToString” as being a member of IEnumerable. You think of it as being a member of the thing that implements IEnumerable.

The paragraph is also flawed because this is the only place “primitive type” appears in the spec, and it appears without definition. It is therefore both unnecessary and confusing and should be removed.

I’ve wanted this paragraph to be fixed for a while. Next time I see Mads I’ll remind him.

To address your specific question: svick is of course correct but it is helpful to see a specific example. When you say:

struct ColorfulInt
{
    int value;
    Color color;
    ...
}

and you create, say, an array:

ColorfulInt[] x = new ColorFulInt[100];

Then the storage for those 100 ints and 100 Colors goes in the array itself. If ColorfulInt were instead a class then the array would contain 100 references to ColorfulInt, each one of which would have to be individually allocated. Individually allocating those hundred elements is much less efficient in both time and space than simply allocating the storage right in the array itself.

2

It means that value types are stored directly where you define them, which makes them more efficient when compared with reference types.

What exactly does that mean? If you have a local variable of a value type it will be usually stored directly on the stack (but there are many exceptions). If you have a field of a value type, it will be stored directly in the enclosing class or structure.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật