7
Answers

Question Converting nested C structure to C# Is this possible?

Photo of Ranandar

Ranandar

16y
8.4k
1
I have a struct written in C that I want to use in C#. It uses an array of structures nested inside of another structure. This is very straightforward in C but I have been unsuccessful in duplicating this simple example. Is this even possible using C#? If it is not possible what other options do I have?

Here is the C code simplified. The actual structure is much more complex.

// -- Message File Structure -- 
        struct message_struct{       // Message Structure 
           char mname[20];             // Message Name 
           char mattr;                 // Message Slot Used flag 
           struct {    // Page             // Page Structure 
              int  duration;         // Duration 
              char stext[201];       // Scroll Buffer 
              struct { // Line         // Line Structure 
                 char csize;         // Char Size 
                 char mchar[31];      // Line Characters 
              } mline[8];            // # of Lines 
           } mpage[10];                 // # of Pages 
        } message;   


Then to access the structure
message.mpage[0].mline[0].mchar[0] = 'A';

Answers (7)

0
Photo of Christian
NA 24 0 15y

Its not the sql query im confused about its more about how the easiest way is to work with a datetime in C# and in sql. I need to have the dates displayed on my webpage but I also need to use the dates for sorting in my sql queries. I coul dsave the datetime as a string in db so it would be easy to retreive it and display it but im just not sure if I would be able to sort with it since its a string in my db. Then I need to save it as a timestamp in the db but I just want to make sure that sql timestamp is easy to work with and easy to convert into string when i want it in my c# code.
0
Photo of Lalit M
NA 6.7k 48k 15y
try this code retreive rows sorted by datetime

SELECT orderID, DATEPART(MM,OrderDate) AS OrderMonth FROM Orders

more info

http://www.sqlmag.com/article/articleid/43488/43488.html
0
Photo of Amit Choudhary
NA 27.7k 3m 15y
hi friend,

Simply using DateTime data type in sqlserver can solve your problem.


Please mark the anser if it helps.