Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C# .NET WinForm
Is there a tool can convert C++ code to C# code.Thank you.
Posted 8-Aug-12 15:29pm
pucx1.2K
Comments
pasztorpisti at 9-Aug-12 2:42am
   
I think its better to convert your code manuall because I don't believe that such an automated translater can do good job. The tools these languages provide are quite different and they have other conceptual differences (like object lifetime). How does this compiler handle different smart pointers - just to pick something I suspect to be hard for the translator. I think the generated C# code for a non-trivial C++ code can only be garbage compared to one that has been redesigned and rewritten by a human. The problem is that often there is no one-on-one mapping because of the conceptual differences - in such cases a new design is needed and the translator won't be thinking istead of you. :-)
Volynsky Alex at 9-Aug-12 11:25am
   
http://forums.asp.net/t/1213219.aspx/1
http://social.msdn.microsoft.com/forums/en-US/csharplanguage/thread/cbcb354b-cfce-4084-a9de-99d6c6779f7d/
http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/b33a2d46-c2a0-45ea-a29d-2c16ac669c52/
http://www.tangiblesoftwaresolutions.com/Product_Details/CPlusPlus_to_CSharp_Converter_Details.html
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

To be honest with you, I have yet to find an automated tool that works better than the human mind. This is probably a task you want to do yourself, why? ..because you can rationalize what makes sense and what doesn't, further more, you can work as the tester in the loop simultaneously by making sure all your translations do what they're supposed to.
 
That's just my opinion, but I don't even like the Visual Studio wizards. They break too easily and they teach new developers to not have to learn what's really going on behind the scenes.
  Permalink  
Comments
pucx at 8-Aug-12 23:56pm
   
I have many codes that is written by C++,I want to convert these to C#.If I convert by hand,a lot of time will waste.Thank you.
Albert Holguin at 9-Aug-12 1:16am
   
Why do you want to convert it anyway? Why not use it and just interface it one way or another?
pasztorpisti at 9-Aug-12 5:02am
   
Good point!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

The best tool is an automated engine driven by precise language parsing, semantics, and rules. In the case of the CLR, you can keep your existing code and add any new features using C# rather than C++.
http://www.dapfor.com/en/net-suite/net-grid/tutorial/data-sorting[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

public static void SendEmail(String emailFrom, String emailTo, String emailCc, String subject, String body, FileInfo[] attachments)
        {
            try
            {
                //create the mail message
                var mail = new MailMessage
                    {
                        From = new MailAddress(emailFrom)
                    };
 
                //set the addresses
                string[] addresses = emailTo.Split(new[] { ';', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string email in addresses)
                {
                    mail.To.Add(email);
                }
 
                addresses = emailCc.Split(new[] { ';', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string email in addresses)
                {
                    mail.CC.Add(email);
                }
 
                foreach (var attached in attachments.Select(attach => new Attachment(attach.FullName, MediaTypeNames.Application.Octet)))
                {
                    mail.Attachments.Add(attached);
                }
 
                //set the content
                mail.Subject = subject;
                mail.Body = body;
 
                var sc = new SmtpClient("smtp.honeywell.com");
                sc.Send(mail);
                MessageBox.Show(Resources.Msg_MailSentSuccessfully, Resources.MsgTitle_Email, MessageBoxButtons.OKCancel);
 
            }
            catch (Exception ex)
            {
                MessageBox.Show(Resources.Msg_ExceptionOccuredinSendingEmail + ex.Message, Resources.MsgTitle_ErrorIsSendingEmail, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
 

        /// <summary>
        /// check email address is valid or not
        /// </summary>
        /// <param name="emailAddress">email address to validate</param>
        /// <returns>True if email address is valid</returns>
        public static bool ValidateEmailAddress(string emailAddress)
        {
            try
            {
                string textToValidate = emailAddress;
                var expression = new Regex(@"\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}");
                return expression.IsMatch(textToValidate);
            }
            catch (Exception)
            {
                return false;
            }
        }
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 404
1 Sergey Alexandrovich Kryukov 387
2 Shemeemsha RA 148
3 Abdul Samad KP 125
4 CPallini 100
0 OriginalGriff 6,189
1 Sergey Alexandrovich Kryukov 5,666
2 CPallini 4,810
3 George Jonsson 3,429
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 29 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100