|
Yes, you can put struct values in a queue, but you probably should not use a struct at all in this case. A struct in .NET is a different concept from a struct in C. In .NET a struct is always a value type, while in C the struct is just a definition of the data and if it's a value type or reference type depends on how you use it.
Use a class like this:
public class AddressMessage {
public long ParameterGroupNumber { get; private set; }
public byte ParameterGroupNumberSpecific { get; private set; }
public byte[] RecievedData { get; private set; }
public AddressMessage(long number, byte specific, byte[] data) {
ParameterGroupNumber = number;
ParameterGroupNumberSpecific = specific;
RecievedData = data;
}
}
C# doesn't use header files at all, and class files are not compiled separately so you don't need header files to share definitions. As long as the class is in the same application, you can reach it by simply specifying the namespace where it is.
Despite everything, the person most likely to be fooling you next is yourself.
modified on Friday, February 20, 2009 4:20 PM
|
|
|
|
|
Thanks for the feedback everyone.
I am porting a C ap to C# and in the legacy code we have a file that handles packets of data that currently arrive as a structure from another file. I would like to pass data into the class file as a structure rather than by seperate set commands so that the data arrives as a combined packet. So am I still wrong to try and do this as a a queue of structs?
Cheers, Bruce
|
|
|
|
|
Yes, you can't read the data directly from the file as a struct anyway, so there is no reason to use a struct at all, use a class.
You can use a BinaryReader to read raw data from a file, but you need to read each value by itself.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Yeah, what they said.
Plus, yes, you can use a header file if you like (I do), but you don't need to and shouldn't.
|
|
|
|
|
PIEBALDconsult wrote: yes, you can use a header file if you like (I do)
I would like to know a little more about that.
TIA
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I want to include the database in my setup file itself . i don't want to setup the database manually. So, how can i do it.
|
|
|
|
|
praveenvkumarv wrote: So, how can i do it.
Well have you started by READING any documentation or articles about creating installers?
|
|
|
|
|
yeh, i have tried using setup and deployment project , i need to embed sqlserver in it.
|
|
|
|
|
praveenvkumarv wrote: i have tried using setup and deployment project
Is that what I asked you?
led mike wrote: have you started by READING any documentation or articles about creating installers?
No, I don't think so. If you are not capable of or willing to Google to find and then READ documentation and articles relating to the technology you need to use then you are not worth my time trying to help you. Have a nice day.
|
|
|
|
|
Yeh, i have searched the Google and codeproject but the demo project in codeproject is not working . Regarding the documentation it is showing to use the firebird database . then i need to change all the code, that's the problem.
|
|
|
|
|
Hello,
Can i print a doc or pdf file with a default printer witch a knew his name? thank you verry mutch.
|
|
|
|
|
abbd wrote:
Can i print a doc or pdf file with a default printer witch a knew his name?
Yes.
(use Google for more information)
Kristian Sixhoej
"You can always become better." - Tiger Woods
|
|
|
|
|
abbd wrote: Can i print a doc or pdf file with a default printer witch a knew his name?
Oh please go ahead. No need to ask.
Yes if you have a printer and paper. And correct connections. Hey! what does this has to do with C#?
The word "politics" describes the process so well: "Poli" in Latin meaning "many" and "tics" meaning "bloodsucking creatures."
जय हिंद
|
|
|
|
|
i would print automatically with my application, thank you verry mutch.
|
|
|
|
|
I do not know whether to use the POSTSCRIPT, I have a virtual printer that is installed, I want to construct a an interface to print the pdf file by this virtual printer, help me please, thank you very much.
|
|
|
|
|
Yes, it certainly is possible to print with a predefined printer, no problem.
But what is your problem?
Is the problem printing the documents/pdf's?
Of is the problem to predefine a printer?
|
|
|
|
|
They are not a problem with printer or pdf, when we would print PDF we must open the pdf file and we click in file and print but i would print the pdf without open it with adobe, when i click on my program, he print the pdf, thank you verry mutch.
|
|
|
|
|
If I have a string "Mr P Smith" is there a way to split the string at the space characters into an array (like the 'explode' method in PHP)? To give:
tempString[0] = "Mr"
tempString[1] = "P"
tempString[2] = "Smith"
|
|
|
|
|
String.Split[^]
Kristian Sixhoej
"You can always become better." - Tiger Woods
|
|
|
|
|
|
Hi
I am working with WindowsApplication in VS 2005.
I want create a UDP client server chat application...
I have a separate Client and Server class...
By default a WindowsApplication has Program.cs file which has a Main()....
I am not able to define a Main() either in Client or Server class...
It gives me an error stating:
Error 1 Program 'C:\Documents and Settings\admin\My Documents\Visual Studio 2005\Projects\WindowsApplication11\WindowsApplication11\obj\Debug\WindowsApplication11.exe' has more than one entry point defined:
What should i do for this?Please explain me this
Thanks for any help in advance.
modified on Friday, February 20, 2009 10:56 AM
|
|
|
|
|
So, do you have a solution with two executable projects in it? I suspect the error message is telling you exactly the problem.
Also, you are aware the UDP is a hopelessly unreliable protocol and you'll need to develop your own error checking if you don't want your messages going missing?
Regards,
Rob Philpott.
|
|
|
|
|
Sounds like the message is correct - suspect a pasted example that has its own main (???)
And I wouldn't go so far as "hopelessly" unreliable. There are times when UDP can be implemented with the same reliability as TCP - at least I "hope" so, or I might have to go back to the basement where I belong before I get to much farther along in my current project (see post above).
---------------------------------------------
Help... I'm embedded and I can't get out!
If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler
|
|
|
|
|
Hi, i'm practicing with c# - c++ dll integration. I reached my first goal, that was to make the c# and c++ sides share a simple struct. This is what i did:
c++ side (NANUReader.dll)
--------------
typedef struct NANUINFO{
int a;
int b;
char* s;
double d;
}NANUINFO;
__declspec(dllexport) void callMe(NANUINFO* info){
info->a = 1;
info->b = 2;
info->s = "hellooo";
info->d = 5.57684;
}
c# side
-------------
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
struct NANUinfo
{
int a;
int b;
string s;
double d;
}
[System.Runtime.InteropServices.DllImport("NANUReader.dll")]
static extern void callMe(ref NANUinfo info);
void callDLLFuntion(){
NANUinfo info = new NANUinfo();
callMe(ref info);
--here info has been filled by the dll--
}
This worked.
Now i would find a way to pass the dll a reference to some sort of empty dynamic collection (like an empty List<nanuinfo>) and make the dll populate it with an unpredictable number of NANUinfo structs. In other words, in the c# side i need something like this:
void callDLLFuntion(){
SomeCollectionType<nanuinfo> infoCollection = new SomeCollectionType<nanuinfo>();
callMe(ref infoColletion);
--here infocollection should be full of NANUinfo structs--
}
I don't even know if this can be achieved. Any help?
Thanks
|
|
|
|
|
bonjour tout le monde
i'am doing pc oscilloscope usb(sine wave) using c#...it's a big headache to me.does anyone know where i could find an example of c# coding(or if someone has done this befor for a help).thanks for your help
|
|
|
|