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 7525373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:31:35+00:00 2026-05-30T03:31:35+00:00

[StructLayout(LayoutKind.Sequential, Size = 280), Serializable] public struct AESContext { /// int nr; [MarshalAsAttribute(UnmanagedType.I4, SizeConst

  • 0
[StructLayout(LayoutKind.Sequential, Size = 280), Serializable]
public struct AESContext
{
    /// int nr; 
    [MarshalAsAttribute(UnmanagedType.I4, SizeConst = 4)]
    public int nr;

    /// unsigned long *rk;
    [MarshalAsAttribute(UnmanagedType.U4, SizeConst = 4)]
    public uint rk;

    // unsigned long buf[68];
    [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 68)]
    public uint[] buf;
}

This is C# struct I have so far. Comment above each field is type in C.
I would love if someone could verify.

  • 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-05-30T03:31:37+00:00Added an answer on May 30, 2026 at 3:31 am

    It sounds like you’re trying to get the C# struct for the C struct defined in the member contents. If so then I believe you want the following

    [StructLayout(LayoutKind.Sequential), Serializable]
    public struct AESContext
    {
        /// int nr; 
        public int nr;
    
        /// unsigned long *rk;
        public UIntPtr rk;
    
        // unsigned long buf[68];
        [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 68)]
        public uint[] buf;
    }
    

    Basic changes

    • Don’t specify SizeConst in StructLayout unless you are trying to create a struct whose size is different (typically) bigger than it’s contents. It’s not very common to do this
    • MarshalAs isn’t usually needed for primitive types
    • Use IntPtr or UIntPtr to PInvoke pointer types. They vary properly in size between 32 and 64 bit platforms
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume that we have two C# structures: [Serializable, StructLayout(LayoutKind.Sequential, Pack = 1)] public struct
I have the following structure: [StructLayout(LayoutKind.Sequential)] public struct TCurve { public int fNumItems; /*
I have a structure [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct SERVER_USB_DEVICE { USB_HWID usbHWID;
I would like to do the following: [StructLayout(LayoutKind.Sequential, Pack = 1)] public struct SomeStruct
I have a struct that looks something like this: [StructLayout(LayoutKind.Sequential)] public struct in_addr {
I have a 3rd party struct that is comprised of the following: [StructLayout(LayoutKind.Sequential, Size=1)]
I have the following struct: [StructLayout(LayoutKind.Sequential, Pack = 1)] struct cAuthLogonChallenge { byte cmd;
how do I declare fixed-size array of a structure type in C# : [StructLayout(LayoutKind.Sequential,Pack=1),
I've the following class [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] public class xy11Dataset
All struct s in C# by default are treated as [StructLayout(LayoutKind.Sequential)] -marked value types.

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.