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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:08:12+00:00 2026-06-01T22:08:12+00:00

Im having very tough challenge in converting the following code C#, can anybody help

  • 0

Im having very tough challenge in converting the following code C#, can anybody help me on how do we do that.

typedef struct ACSNameAddr_t {
    char FAR *serverName;    // How do i use FAR in C#
    struct {
        short length;
        unsigned char FAR *value;
    } serverAddr;
} ACSNameAddr_t;

and how do i use this union in C#

typedef struct
{
    union
    {
        CSTARouteRegisterAbortEvent_t   registerAbort;
        CSTARouteUsedEvent_t            routeUsed;
        CSTARouteUsedExtEvent_t         routeUsedExt;
        CSTARouteEndEvent_t             routeEnd;
        CSTAPrivateEvent_t              privateEvent;
        CSTASysStatEvent_t              sysStat;
        CSTASysStatEndedEvent_t         sysStatEnded;
    }u;
} CSTAEventReport;

Edit Answer:

So including all your answers, here by i’m writing the converted code. Please edit it if there is anything wrong, it might be useful for someone..

[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct ACSNameAddr_t
{
    string serverName;
    [StructLayout(LayoutKind.Sequential, Pack = 4)]
    public struct serverAddr
    {
        public short length;
        string value;
    };
};

and for the second one,

[StructLayout(LayoutKind.Explicit, Pack = 4)]
    public struct CSTAEventReport{
        [StructLayout(LayoutKind.Explicit, Pack = 4)]
        public struct u{
            [FieldOffset(0)]
            public CSTARouteRegisterAbortEvent_t registerAbort;
            [FieldOffset(0)]
            public CSTARouteUsedEvent_t routeUsed;
            [FieldOffset(0)]
            public CSTARouteUsedExtEvent_t routeUsedExt;
            [FieldOffset(0)]
            public CSTARouteEndEvent_t routeEnd;
            [FieldOffset(0)]
            public CSTAPrivateEvent_t privateEvent;
            [FieldOffset(0)]
            public CSTASysStatEvent_t sysStat;
            [FieldOffset(0)]
            public CSTASysStatEndedEvent_t sysStatEnded;
        };
};
  • 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-01T22:08:14+00:00Added an answer on June 1, 2026 at 10:08 pm

    So including all your answers, here by i’m writing the converted code. Please edit it if there is anything wrong, it might be useful for someone..

    [StructLayout(LayoutKind.Sequential, Pack = 4)] 
    public struct ACSNameAddr_t 
    { 
        string serverName; 
        [StructLayout(LayoutKind.Sequential, Pack = 4)] 
        public struct serverAddr 
        { 
            public short length; 
            string value; 
        }; 
    }; 
    

    and for the second one,

    [StructLayout(LayoutKind.Explicit, Pack = 4)] 
        public struct CSTAEventReport{ 
            [StructLayout(LayoutKind.Explicit, Pack = 4)] 
            public struct u{ 
                [FieldOffset(0)] 
                public CSTARouteRegisterAbortEvent_t registerAbort; 
                [FieldOffset(0)] 
                public CSTARouteUsedEvent_t routeUsed; 
                [FieldOffset(0)] 
                public CSTARouteUsedExtEvent_t routeUsedExt; 
                [FieldOffset(0)] 
                public CSTARouteEndEvent_t routeEnd; 
                [FieldOffset(0)] 
                public CSTAPrivateEvent_t privateEvent; 
                [FieldOffset(0)] 
                public CSTASysStatEvent_t sysStat; 
                [FieldOffset(0)] 
                public CSTASysStatEndedEvent_t sysStatEnded; 
            }; 
    }; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a very tough time debugging a multi-threaded C application that I've made
Im having a very strange problem, i have a complicated view that returns incorrect
I'm having a very big struct in an existing program. This struct includes a
I am having a very specific problem in JQuery The code below is used
I am having a very tough time with this one. I have a Navigation
I am having a very weird problem that I've never had before when using
I am having a discussion with someone about the following table that is used
I am following along very closely with the code within the GeoCongress.us App ,
I'm having a very common problem that I don't know how to fix for
Im having a very odd problem. Im trying to install a Python program. Im

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.