Click here to Skip to main content
14,331,194 members
   

C#

 
GeneralRe: My thoughts on C# Pin
Brian_TheLion2-Jun-19 15:56
memberBrian_TheLion2-Jun-19 15:56 
GeneralRe: My thoughts on C# Pin
#realJSOP3-Jun-19 0:15
mve#realJSOP3-Jun-19 0:15 
GeneralRe: My thoughts on C# Pin
Dave Kreskowiak3-Jun-19 2:37
mveDave Kreskowiak3-Jun-19 2:37 
GeneralRe: My thoughts on C# Pin
Brian_TheLion3-Jun-19 12:22
memberBrian_TheLion3-Jun-19 12:22 
GeneralRe: My thoughts on C# Pin
Brian_TheLion2-Jun-19 15:17
memberBrian_TheLion2-Jun-19 15:17 
GeneralRe: My thoughts on C# Pin
BillWoodruff1-Jun-19 17:40
mveBillWoodruff1-Jun-19 17:40 
GeneralRe: My thoughts on C# Pin
Brian_TheLion1-Jun-19 18:02
memberBrian_TheLion1-Jun-19 18:02 
GeneralRe: My thoughts on C# Pin
OriginalGriff1-Jun-19 20:16
protectorOriginalGriff1-Jun-19 20:16 
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!

GeneralRe: My thoughts on C# Pin
Brian_TheLion1-Jun-19 20:37
memberBrian_TheLion1-Jun-19 20:37 
GeneralRe: My thoughts on C# Pin
phil.o1-Jun-19 22:02
mvephil.o1-Jun-19 22:02 
GeneralRe: My thoughts on C# Pin
Brian_TheLion2-Jun-19 16:16
memberBrian_TheLion2-Jun-19 16:16 
GeneralRe: My thoughts on C# Pin
OriginalGriff1-Jun-19 22:47
protectorOriginalGriff1-Jun-19 22:47 
GeneralRe: My thoughts on C# Pin
Brian_TheLion2-Jun-19 15:45
memberBrian_TheLion2-Jun-19 15:45 
GeneralRe: My thoughts on C# Pin
Dave Kreskowiak2-Jun-19 6:10
mveDave Kreskowiak2-Jun-19 6:10 
GeneralRe: My thoughts on C# Pin
Brian_TheLion2-Jun-19 15:32
memberBrian_TheLion2-Jun-19 15:32 
GeneralRe: My thoughts on C# Pin
Brian_TheLion3-Jun-19 12:49
memberBrian_TheLion3-Jun-19 12:49 
GeneralRe: My thoughts on C# Pin
BillWoodruff2-Jun-19 20:07
mveBillWoodruff2-Jun-19 20:07 
GeneralRe: My thoughts on C# Pin
Brian_TheLion3-Jun-19 12:40
memberBrian_TheLion3-Jun-19 12:40 
GeneralRe: My thoughts on C# Pin
Richard MacCutchan1-Jun-19 21:46
protectorRichard MacCutchan1-Jun-19 21:46 
GeneralRe: My thoughts on C# Pin
Brian_TheLion2-Jun-19 0:15
memberBrian_TheLion2-Jun-19 0:15 
GeneralRe: My thoughts on C# Pin
Mycroft Holmes2-Jun-19 13:36
memberMycroft Holmes2-Jun-19 13:36 
GeneralRe: My thoughts on C# Pin
Brian_TheLion2-Jun-19 15:22
memberBrian_TheLion2-Jun-19 15:22 
GeneralRe: My thoughts on C# Pin
Mycroft Holmes2-Jun-19 15:58
memberMycroft Holmes2-Jun-19 15:58 
GeneralRe: My thoughts on C# Pin
Brian_TheLion2-Jun-19 16:50
memberBrian_TheLion2-Jun-19 16:50 
GeneralRe: My thoughts on C# Pin
jsc423-Jun-19 23:18
professionaljsc423-Jun-19 23:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.