473,466 Members | 1,395 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ansi c code in c# class

Hi, I'm developin windows forms app in c#. I would like to use Ansi C
algoritm in one of method of my app. Can I do that?

May 10 '06 #1
4 3619

"Marek" wrote...
Hi, I'm developin windows forms app in c#.
I would like to use Ansi C algoritm in one of
method of my app. Can I do that?


That depends on what you really mean...

Yes, you should be able to use the *algorithm* from your Ansi C code, though
you probably will have to make some adjustments.

No, you can't just "cut and paste" Ansi C code into a C# source file, unless
it uses only primitive elements, no built in C-functions and no pointers.

/// Bjorn A
May 10 '06 #2
Hello, Marek!

M> Hi, I'm developin windows forms app in c#. I would like to use Ansi C
M> algoritm in one of method of my app. Can I do that?

Yes, you can, if it is an alogrithm then it can be implemented on different programming languages...

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
May 10 '06 #3

"Bjorn Abelli" <bj**********@DoNotSpam.hotmail.com> wrote in message
news:OG**************@TK2MSFTNGP02.phx.gbl...

"Marek" wrote...
Hi, I'm developin windows forms app in c#.
I would like to use Ansi C algoritm in one of
method of my app. Can I do that?


That depends on what you really mean...

Yes, you should be able to use the *algorithm* from your Ansi C code,
though you probably will have to make some adjustments.

No, you can't just "cut and paste" Ansi C code into a C# source file,
unless it uses only primitive elements, no built in C-functions and no
pointers.


Yes you can use pointers just fine - just use the "fixed" keyword.

I have ported a CRC algorithm with almost no change - but there aren't many
algorithms that are complicated enough to want to port and yet don't call a
whole load of stuff that you can't use.

You can even call most C functions using P/Invoke - but it's a lot of
effort.
May 10 '06 #4
> Yes you can use pointers just fine - just use the "fixed" keyword.
Yes but be sure you *need* to. Writing unsafe code introduces stability and
security risks. I would make sure the framework doesn't offer the required
functionality out of the box first. If it doesn't perhaps you can rework the
algorithm without having to resort to unsafe code. Unsafe code should be the
last resort...

Regards
Lee

"Nick Hounsome" <Ne**@NickHounsome.Me.Uk> wrote in message
news:73******************@text.news.blueyonder.co. uk...

"Bjorn Abelli" <bj**********@DoNotSpam.hotmail.com> wrote in message
news:OG**************@TK2MSFTNGP02.phx.gbl...

"Marek" wrote...
Hi, I'm developin windows forms app in c#.
I would like to use Ansi C algoritm in one of
method of my app. Can I do that?


That depends on what you really mean...

Yes, you should be able to use the *algorithm* from your Ansi C code,
though you probably will have to make some adjustments.

No, you can't just "cut and paste" Ansi C code into a C# source file,
unless it uses only primitive elements, no built in C-functions and no
pointers.


Yes you can use pointers just fine - just use the "fixed" keyword.

I have ported a CRC algorithm with almost no change - but there aren't
many algorithms that are complicated enough to want to port and yet don't
call a whole load of stuff that you can't use.

You can even call most C functions using P/Invoke - but it's a lot of
effort.

May 10 '06 #5

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

Similar topics

0
by: Eric Myers | last post by:
Hello folks: (This message is also posted on the help forum at the pexpect sourceforge page, but all indentation in the code got stripped away when I submitted the post.) For some time I've...
3
by: Sunil Menon | last post by:
Dear All, A class having no member variables and only a method sizeof(object) will return 1byte in ANSI and two bytes in Unicode. I have the answer for this of how in works in ANSI. But I don't...
4
by: Mark Huppert | last post by:
Dear Colleagues re: 'using' and the ANSI C++ standard According to the ANSI C++ standard, is this a valid way (disregarding whether it is 'naughty') of converting a public method in the base...
7
by: | last post by:
Borland dumped all its "Borand C++ Builder" (BCB) customers. So it is our term to dump Borland (not only BCB). As a part of my attempt to dump long-loved BCB I'm trying to investigate how one can ...
100
by: Roose | last post by:
Just to make a tangential point here, in case anyone new to C doesn't understand what all these flame wars are about. Shorthand title: "My boss would fire me if I wrote 100% ANSI C code" We...
25
by: Amarendra GODBOLE | last post by:
Hi, I am working on a legacy user space app, which has been developed entirely in C, some 15 years ago. Needless to say, it does not even partially conform to any standard. My team is in the...
2
by: Martín Marconcini | last post by:
Hello there, I'm writting (or trying to) a Console Application in C#. I has to be console. I remember back in the old days of Cobol (Unisys), Clipper and even Basic, I used to use a program...
10
by: Michael B. Trausch | last post by:
Alright... I am attempting to find a way to parse ANSI text from a telnet application. However, I am experiencing a bit of trouble. What I want to do is have all ANSI sequences _removed_ from...
47
by: Thierry Chappuis | last post by:
Hi, I'm interested in techniques used to program in an object-oriented way using the C ANSI language. I'm studying the GObject library and Laurent Deniau's OOPC framework published on his web...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.