Brian_TheLion wrote:I have a program I want to convert to C#.
And there is your problem!
You are taking an existing C++ program and assuming that the "best idea" is to translate it to C#, because C++ and C# are so similar.
But they aren't. They are completely different languages that share some common syntax. They work differently.
Ignore computers for a moment and think about languages. Write a letter to your friend in English.
You then remember that Hans doesn't speak English, only German. So what do you do? Well, they both use the same alphabet, so it can' be that hard. Grab a English-German dictionary, and look up each word in turn. You will end up with a letter full of German words - but is it a good German letter? Does it make sense? Does it say what you wrote the original to say? Almost certainly not, because the English word "Current" for example, has many different meanings: "the flow of water", "the power of electricity", "modern and trendy", "a dried grape" which will all have different words in German: "die Strömung", "der Strom", "gegenwärtig", "die Rosine". Which one did you use?
Literal translation doesn't work for languages - that's why Google translate is so incredible, it tries to work out from the whole context what you are talking about. In fact it lists many different translations for "Current":
derStrom current, power, stream, electricity, flux, river
Strömung flow, current, stream, trend, drift, tendency
aktuell current, latest, actual, topical, up, relevant
gegenwärtig present, current, existing
laufend running, ongoing, current, present, routine, runny
derzeitig current, present, prevailing, of that time
augenblicklich present, current, immediate, momentary, temporary
geltend established, current, in force, prevailing, operative
gebräuchlich common, customary, usual, conventional, current, standard
gängig common, popular, current, going, possible
bestehend existing, established, present, current, standing, prevailing
jetzig present, current
nunmehrig current, present
herrschend ruling, reigning, dominant, prevalent, prevailing, current
marktgängig marketable, merchantable, current
And it will use the appropriate one. Google Translate[^]
So ... back to computers. Why would a "literal translation" of C++ work as a C# program?
The answer is, it doesn't. C++ comes with a lot of "baggage" because it evolved from C with added OOPs and has been expanded and modified by a huge committee since then. C# was a new-from-the-ground-up language designed for object orientation (and is being modified by a huge committee so ...) which shares some common syntax.
Translating letters word by word doesn't work: you write a new letter that means the same thing.
Translating programs doesn't work: it produces bad code in the "destination" language. Instead, use the original as a specification, and rewrite the code for the new language. That way, you get good code that does the same job.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!