Well, I am still reawriting my bic C++ library to C# and found an other problem. When reading one of the file format (MD2) you are supposed to read unsign chars. Is there something like that in C#? I can't find it...hmmm...any help?
- ØØ -
Printable View
Well, I am still reawriting my bic C++ library to C# and found an other problem. When reading one of the file format (MD2) you are supposed to read unsign chars. Is there something like that in C#? I can't find it...hmmm...any help?
- ØØ -
Is this unsigned char 1 byte or 2? If it's 2 then you should use a UInt16. There is no unsigned 1-byte type in .NET so I'd guess you'd just have to use a Byte if it's 1 byte.
It is 2bytes (16bits). The same as with all the other datatypes. But I think maybe using a "string" would be better? Or what? Isn't a string 16bits in C#? And unsigned, isn't it? I can try both and see what happens.
- ØØ -
Using a char as a number was really a hack in C++. From the name, obviously it is supposed to represent a character so treating it as a number was a convenience. A UInt16, Int16 and Char are all 2 bytes in .NET but are all intended for different, specific purposes. A string in C# is a 32-bit stack reference to an object on the heap. Quite different I would say.
OK, I don't have my books here, and I don't have internet on the computer I am programming on right now, so I have to run back and forth, so I just looked it up on the internet at the same time as I wrote the post. Here is what I found:
http://codemonkey.sunsite.dk/trainin...arpprimer.html
I guess that page is wrong then, or maybe my big sick bloaty head missunderstands it. But to be honest, I think it depends on how it has been all ready used. If they are using "unsigned char" as a number then I guess UInt16 is the right one, but if they are using it as a char then I guess string might pull it off, unless you are 100% right, and that web page or I am missunderstanding it...:) (the latter one are very likely today...I bet my head is on the size of a hot air baloon on the end of the day anyway..:))Code:BUILT-IN NAMESPACE SIZE VALUES
-------- -------------- ---------- -----------
bool System.Boolean 1 bit true false
byte System.Byte 8 bits 0 -> 255
sbyte System.SByte signed byte -128 -> 127
char System.Char 16 bits unicode txt*
string System.String 2 bytes/char unicode txt*
decimal System.Decimal 2 bytes $ currency $double System.Double 4 bytes 320 sig places
float System.Single 2 bytes 32 sig places
int System.Int32 2 bytes -65363 -> +65363
uint System.UInt32 long System.Int64 4 bytes
ulong System.UInt64 short System.Int16 1 byte
ushort System.UInt16
object System.Object -------- -------------- ---------- -----------
BUILT-IN NAMESPACE SIZE VALUES
- ØØ -
I'm not sure where the author of that page got there information but I believe that it is incorrect. For a start, they say that the an int is 2 bytes and ranges from -65363 to 65363. The help topic for the int type clearly states that an int is 32 bits, or 4 bytes, in size and ranges from -2,147,483,648 to 2,147,483,647. Given that the int type is implemented using the System.Int32 structure, the name alone would suggest that it is 32-bit or 4-byte. The same goes for the Int16, which is 16-bit or 2-byte, not 1-byte. Also, the System.Boolean is a bona fide structure. It is not represented by a single bit as that page suggests. I'm afraid that that section at least of that page is complete cr*p.
Edit:
The bit about the string type is cr*p too. The System.String class is not directly related to the System.Char structure. A char is stored on the stack, while a string is a stack reference to a heap object. If you're working on a 32-bit machine then I believe that all reference variables are 32-bit, or perhaps I'm wrong and they are transalted from 16-bit aliases. I doubt that though.
Well....I think it is working now...but I can't see anyting on the screen at the moment, so I have to make a camera class first. And with my bloaty head it will probably take a few days to get that far...:)
But thanks for all your time and help. I guess that page is outdated...and I will make sure I don't bookmark it at work..:)
Thanks
- ØØ -