Just being correct? You make it sound like you've searched the internet from 0 to -1 and have come to the conclusion that there is absolutely no way to accomplish said task.Quote:
@Bone, actually in my original post i said that it works well for everything except to packets which dont work because of the need for variable sized arrays, and you came back with of course it can be done with dynamic values, so im not being hostile, im just being correct, you cannot do it thats the end of it. You can work around it using constructs which of course can be done, sadly its alot less elegant and requires more processing and cpu time. But that is a work around to something that they should have more sense about when designing the language. :(
As for constructs, dur. They will never be as "elegant" as a straight struct, but it's at no cost of processing because it has to be done anyway. No matter how you look at it, you're still having to build the packet piece by piece whether you call a construct function to do it for you or do it manually per packet in the app itself (which is totally bad practice and messy). You're doing it anyway, might as well do it in a more efficient manner.
And to "sense", lol. Do I even need to comment on that? You do not know what goes on at the low-level. You use C# explicitly. Unfortunately, as much as C# will wipe your program's ass for it and feed it automatically, it is not the god of all languages and was designed to be a more RAD java+vb+c++ and it maintains many of the same limitations and features. Sure, as said maybe in the future it will be possible, but it's not entirely practical on a .NET coding level. Just to do it they (microsoft) will have to add so many checks and shit for dynamic sizes of structs. All the struct is now, in a managed sense (typedef var[]) is just a pointer to C#. It is exactly the same as C++. Difference is, C# does not expose the pointer sense to you completely and tries to encapsulate it in the struct to make it seem as one, but it still holds the same limitations of a pointer. Hell, you could probably get around it with built in C# functions of doing foreach on the types and finding what is a pointer and copying it to a premade buffer. Now THAT would be highly inefficient processing wise and would be accomplished the same on a .NET level if it was implemented. Your best bet is to know beforehand what you are dealing with and coding it as such. Any time you try to make something dynamic you are almost always sacrificing processing time to make it possible.