C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2720
Number of posts: 5746

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How to convert this c code to C# Posted by vipulgondalia on 17 Aug 2004 at 3:03 AM
Hi friends,
I am an newbie to C#.NET. I had one program in which i am copying one DBF file to one buffer named BUFI and then getting some information like no. of fields/records/headersize etc. In C language, I used to get this information directly like :

fields = ((*((short *)(bufi+8)))-32)/32;
recs = *((long *)(bufi+4));
recsz = *((short *)(bufi+10));
headsz = *((short *)(bufi+8));

How can i get information using C#. Thanks in advance.
Report
Re: How to convert this c code to C# Posted by heile on 23 Aug 2004 at 11:12 PM
: Hi friends,
: I am an newbie to C#.NET. I had one program in which i am copying one DBF file to one buffer named BUFI and then getting some information like no. of fields/records/headersize etc. In C language, I used to get this information directly like :
:
: fields = ((*((short *)(bufi+8)))-32)/32;
: recs = *((long *)(bufi+4));
: recsz = *((short *)(bufi+10));
: headsz = *((short *)(bufi+8));
:
: How can i get information using C#. Thanks in advance.
:

This may sound like a stupid question, so sorry in advance, but have you tried to compile this code yet? From what I have read, C/C++ code maps pretty well to C#( with a few exceptions i.e. keyword, packages, ...).

I am little confused what you are trying to do. What it appears to me you are doing is, using pointer dereferencing, trying to get the contents of an array(bufi) at certain indexes.

If may help if you either post or e-mail me the entire c file and I see what I can do.

BTW, Concerning your quest for C# info, there are many sites that can help you. I would start with MSDN then try codeproject, gotdotnet, here maybe, and if all else fails you can try googling (C + C/C++ + C# + tutorials) and see what it brings up.

Hope this helps :)
Report
Re: How to convert this c code to C# Posted by ing_gigio on 27 Aug 2004 at 5:25 PM
: : Hi friends,
: : I am an newbie to C#.NET. I had one program in which i am copying one DBF file to one buffer named BUFI and then getting some information like no. of fields/records/headersize etc. In C language, I used to get this information directly like :
: :
: : fields = ((*((short *)(bufi+8)))-32)/32;
: : recs = *((long *)(bufi+4));
: : recsz = *((short *)(bufi+10));
: : headsz = *((short *)(bufi+8));
: :
: : How can i get information using C#. Thanks in advance.
: :
:
: This may sound like a stupid question, so sorry in advance, but have you tried to compile this code yet? From what I have read, C/C++ code maps pretty well to C#( with a few exceptions i.e. keyword, packages, ...).
:
: I am little confused what you are trying to do. What it appears to me you are doing is, using pointer dereferencing, trying to get the contents of an array(bufi) at certain indexes.
:
: If may help if you either post or e-mail me the entire c file and I see what I can do.
:
: BTW, Concerning your quest for C# info, there are many sites that can help you. I would start with MSDN then try codeproject, gotdotnet, here maybe, and if all else fails you can try googling (C + C/C++ + C# + tutorials) and see what it brings up.
:
: Hope this helps :)
:

I don't think this code could compile under .NET for the simple reason that in .NET there's not the concept of pointer. What's get closer to it it's a reference but its syntax it's different.

As someone already suggested, it would be easier to help u with the whole code or a lil deeper explaination
Report
Re: How to convert this c code to C# Posted by Baldusarius on 27 Aug 2004 at 5:38 PM
: : : Hi friends,
: : : I am an newbie to C#.NET. I had one program in which i am copying one DBF file to one buffer named BUFI and then getting some information like no. of fields/records/headersize etc. In C language, I used to get this information directly like :
: : :
: : : fields = ((*((short *)(bufi+8)))-32)/32;
: : : recs = *((long *)(bufi+4));
: : : recsz = *((short *)(bufi+10));
: : : headsz = *((short *)(bufi+8));
: : :
: : : How can i get information using C#. Thanks in advance.
: : :
: :
: : This may sound like a stupid question, so sorry in advance, but have you tried to compile this code yet? From what I have read, C/C++ code maps pretty well to C#( with a few exceptions i.e. keyword, packages, ...).
: :
: : I am little confused what you are trying to do. What it appears to me you are doing is, using pointer dereferencing, trying to get the contents of an array(bufi) at certain indexes.
: :
: : If may help if you either post or e-mail me the entire c file and I see what I can do.
: :
: : BTW, Concerning your quest for C# info, there are many sites that can help you. I would start with MSDN then try codeproject, gotdotnet, here maybe, and if all else fails you can try googling (C + C/C++ + C# + tutorials) and see what it brings up.
: :
: : Hope this helps :)
: :
:
: I don't think this code could compile under .NET for the simple reason that in .NET there's not the concept of pointer. What's get closer to it it's a reference but its syntax it's different.
:
: As someone already suggested, it would be easier to help u with the whole code or a lil deeper explaination
:

Actually, C# allows the use of pointers in blocks of code marked "unsafe". There will only be a miniscule number of cases they're actually needed, though.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.