5 Replies - 4259 Views - Last Post: 09 August 2010 - 02:26 AM Rate Topic: -----

#1 SweetyK   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 27-June 10

Code Conversion from c++ to c#

Posted 06 August 2010 - 03:05 AM

Hello,
I need to convert c++ code to c#
I dont have much idea of c++ so can you please help
Equivalent for following in c#
Position is an int and CodeParser,

struct CodeEffect { // defines what happens when a datum is processed
    CodeAction          action;
    const CodeState*    next;
    bool                markPosition;
};



1. typedef void (CodeParser::Context::*CodeAction)(CodeParser::Position);
2. #ifndef NDEBUG

I would be very thankful for the help.

This post has been edited by JackOfAllTrades: 06 August 2010 - 05:01 AM
Reason for edit:: Added code tags.


Is This A Good Question/Topic? 0
  • +

Replies To: Code Conversion from c++ to c#

#2 Crunch   User is offline

  • D.I.C Lover
  • member icon

Reputation: 139
  • View blog
  • Posts: 1,222
  • Joined: 28-July 09

Re: Code Conversion from c++ to c#

Posted 06 August 2010 - 04:47 AM

Identical post's

:gun_bandana: http://www.dreaminco...ode-conversion/
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6260
  • View blog
  • Posts: 24,030
  • Joined: 23-August 08

Re: Code Conversion from c++ to c#

Posted 06 August 2010 - 05:01 AM

Closed C++ duplicate topic.
Was This Post Helpful? 0
  • +
  • -

#4 Bacanze   User is offline

  • D.I.C Head

Reputation: 36
  • View blog
  • Posts: 202
  • Joined: 09-April 10

Re: Code Conversion from c++ to c#

Posted 06 August 2010 - 07:50 AM

I have never written any C++, so I'm sure someone can do a better job, but I'll have a shot, making some assumptions though.

public class CodeEffect // defines what happens when a datum is processed
{
	public CodeAction action = new CodeAction();
	public CodeState next;
	public bool markPosition;
}



The next two lines I'm really not sure on typedef is defining your own custom type I think (quite a cool idea). Erm maybe a delegate?
Was This Post Helpful? 0
  • +
  • -

#5 SweetyK   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 27-June 10

Re: Code Conversion from c++ to c#

Posted 08 August 2010 - 11:10 PM

View PostJackOfAllTrades, on 06 August 2010 - 04:01 AM, said:

Closed C++ duplicate topic.


I am not sure but my interpretation for the code is as follows:

Code Action should be an delegate for which I will have to write an handler which accepts Position (int)as an parameter to this function.

Debug is used to identify that if the code is running in debug mode.
And equivalent can be
if !DEBUG //in C#
endif

Can any 1 tell me that is my interpretation is right or wrong.
Thank you,
Was This Post Helpful? 0
  • +
  • -

#6 SweetyK   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 27-June 10

Re: Code Conversion from c++ to c#

Posted 09 August 2010 - 02:26 AM

Hello,
Can you help me doing this ?
CodeState::const_iterator effectIter
( itsState->find(d) );

itsState is an map -- so i took dictionary for it.
Find equivalent can be ContainsKey(d)

but const_iterator?? What type is this? What equivalent can i have in c#
Shall i have an foreach loop?

but its an return type?
So what can be appropriate equivalent?

Thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1