Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7852861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:31:18+00:00 2026-06-02T19:31:18+00:00

Is it possible to declare struct array field in another struct ? [StructLayout(LayoutKind.Sequential, Pack

  • 0

Is it possible to declare struct array field in another struct?

[StructLayout(LayoutKind.Sequential, Pack = 1)]
public unsafe struct A
{
}

[StructLayout(LayoutKind.Sequential, Pack = 1)]
public unsafe struct B
{
    public fixed A FieldA[123];
}

Visual Studio tells that FieldA can only be an array of any simple type not a struct. Is there any solution/workaround here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:31:19+00:00Added an answer on June 2, 2026 at 7:31 pm

    Is it possible to declare struct array field in another struct?

    Yes, but there are restrictions if you want to make it a fixed-size buffer. From section 18.7.1 of the C# 4 spec:

    The buffer element type of a fixed size buffer declaration specifies the element type of the buffer(s) introduced by the declaration. The buffer element type must be one of the predefined types sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, or bool.

    I don’t know of any alternatives to emulate fixed sized buffers of arbitrary structs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Cannot declare Public static final String s = new String(“123”) inside an
In Java, is it possible to declare a field/variable whose type is multiple interfaces?
Is it posible to declare a global array of a struct, and add elements
Possible Duplicate: undefined C struct forward declaration How is it possible to declare a
let us suppose some (legacy) code, which cannot be touched, declare struct B{ public:
Is it possible to forward-declare a class declared in another forward-declared class? Basically, I
Is it possible to declare a #define statement like this somehow? #define #Name# struct->name
Possible Duplicates: How to initialize array of struct? Initializing an Array of Structs in
I am trying to declare a struct that is dependent upon another struct. I
Is it possible to declare more than one variable using a with statement in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.