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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:27:42+00:00 2026-05-14T16:27:42+00:00

I have an unmanaged struct I’d like to marshal to c# that looks basically

  • 0

I have an unmanaged struct I’d like to marshal to c# that looks basically like this:

struct DateTimeStruct{
   double datetimestamp;
};   

struct MyStruct{
   char firstname[40];
   char lastname[40];
   DateTimeStruct bday;
   unsigned integer bool1;
   int val1;
};

What is the the correct c# declaration?

  • 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-14T16:27:43+00:00Added an answer on May 14, 2026 at 4:27 pm

    The struct isn’t a problem, it will marshal correctly as-is.

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        struct MyStruct{
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 40]
            string firstname;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 40]
            string lastname;
            DateTimeStruct bday;
            uint bool1;
            int val1;
        }
    

    Of course, it will be up to you to convert the double to a matching DateTime value. How it is encoded is unguessable from your question.

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

Sidebar

Related Questions

I have an unmanaged struct I'd like to marshal to c sharp that looks
I have a C++ struct that looks like this: struct unmanagedstruct { int flags;
I have an unmanaged COM object, and I would like to call it from
Here's my problem: I have an unmanaged dll that I made.I'm calling one of
I have a collection of unmanaged dlls with a C# wrapper around them that
I have a closed source unmanaged DLL coded in C++ that I wanted to
Alright, so this is getting very very annoying. I have an unmanaged VC 2010
I have a legacy DLL written in C that I'd like to call from
I have an unmanaged method that when executed takes high CPU. Is it safe
I have a C++ unmanaged class NativeDog that needs to be used from C#,

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.