473,385 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Struct vs Class and using MarshalAs

Bob
I have an old project written in VC++ that I want to convert to C#. In the old project I have a structure that has an array within it that is predefined to be 10 elements long. Anyway, I had issues setting this up without using the MarshalAs unmanaged and then setting the array size. Seems to me that this takes away from the managed code scheme of things. So I was wondering if I was better off setting it up as a class of it's own and simply having no methods to it or leaving it as unmanged code in a managed code environment

Here is cutout of what I am doing now..

public struct StyleSheet

public string strTagname
public string strTagContext
public System.Drawing.Font Font;
public System.Drawing.Color FontColor, BackgroundColor, rgbAlternateColor
public short LineSpace
public short SpaceAbove, SpaceBelow
public short IndentLeft, IndentRight, IndentFirst
[MarshalAs(UnmanagedType.ByValArray, SizeConst=MAXTABS)]
public short[] tabsArray
public short justification
public ushort Flags, ActualFlags
public string strTextBefore
public string strpTextAfter
public string Emph
public ushort InheritanceFlags; // Use to be WOR
public string LinkAttribute
public byte BorderStyle
public byte SpecialEmph
public byte ChangeLevel
public ushort AutonumberStyle
public int iMatchWeight
}

Nov 16 '05 #1
0 938

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Arne Styve | last post by:
Hi, I have an API written in C that came with some graphics cards we are going to use in a project. I need to write a small application where this API is to be used, and I decided to try out...
6
by: Angel | last post by:
I'm exporting (with DllImport) a C-style function with this syntax: int z9indqry (4_PARM *parm); 4_PARM is a structure declared in a proprietary header file that cannot be included in my...
3
by: VMI | last post by:
How can I convert the following C struct into a C# struct? The struct is sent to an API function (written in C) as parameter, and the function fills it with data. I tried to convert it and most of...
6
by: SB | last post by:
I feel dumb to ask because I bet this is a simple question... Looking at the code below, can someone please explain why I get two different values in my Marshal.SizeOf calls (see the commented...
4
by: DaHool | last post by:
Hi there !!! I browsed around the Internet in search for a solution of a little difficult problem i have in VB.NET.... However, i cannot find a suitable anwser anywhere, so i thought i'll give...
4
by: taskswap | last post by:
I'm converting an application that relies heavily on a binary network protocol. Within this protocol are a lot of byte arrays of character data, like: public unsafe struct MsgAddEntry {...
1
by: jsshah | last post by:
Hi I want to marshal following Win32 struct into .NEt class or struct as I want to call a native dll function from a Csharp code. The win32 struct ----------------------- typedef struct...
1
by: eastlands | last post by:
I need to use an unmanaged c++ dll which uses structs that contain callbacks and also functions. I have included the appropriate c++ definitials and my c# translations below. I first defined the...
2
by: =?Utf-8?B?dmxhZGltaXI=?= | last post by:
Hi, i have big subsystem written in old C and published by dll (and lib). Dll functions do: 1) allocate global memory for internal structures 2) controls dll subsystem (communicate by sockets,...
1
by: elke | last post by:
Hi, I want to use an unmanaged dll in C# .net and I'm having some troubles witch a function that should return an array. I'm new at this, so I don't know what I'm doing wrong. Here is some...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.