The table on the following pages compares the statement types available in C++ and C# and describes their use.
Statement Type | C++ Statement | C# Statement |
---|---|---|
Char Array Sizing | char[]charSS = newchar[6]; | |
Char Array to String | strFilename = newstring(charFilename); | |
Close | close(); | No change |
Close File | fclose(fd); | fs.Close(); |
Decrement Variable | ItemNo--; | No change |
Digit Check | if(Char.IsDigit(textBox2.Text[1])) { } else { } ; | |
Directory Create | Directory.CreateDirectory("A:\\DDT"); | |
Directory Exists? | if(Directory.Exists("A:\\DDT") | |
Draw Line | grfx.DrawLine(blackPen, 70+DX, 445, DX, 455); | |
Enable/Disable | Button1->Enabled = false; | button1.Enabled = false; |
Encoding | StreamWriter x5 = newStreamWriter(Filename, true, Encoding.ASCII, 62) | |
Exit | exit(1); | No change |
File Copy | FileCopy() or CopyFile() | See CF043-CF044 in the App C -- KTVC#TaggedCode.doc file. |
File Append | if((fy = fopen("Filename", "at")) == NULL; | See 'StreamWriter', line SU0855 in the App C -- KTVC#TaggedCode.doc file. |
File Length | Length = filelength(fd); | intLength = fs.Length; |
File Read | fread(charWNW, sizeof(charMNDummy), 1, ff); | ww.ReadBlock(charDDTBlock, 0, 62); |
File Write | fwrite(&charRecordStor[0], sizeof(Dummy), 1, fp); | xd.Write(strMNRecord); |
Floatto String Format | strYW = ConvertToString(doubleJJ); | |
For | for(int pp = 0; pp < NORFORM1; pp++) | No change |
GoTo | goto JUMP1; | No change |
Graphics | Graphics grfx = ppea.Graphics; | |
If | if(FlagFlag == 0) { }; | No change |
Include | #include | using System.xxx |
Increment Variable | ItemNo++; | No change |
Initiate Program | WinExec("KTPlot.exe", SW_SHOWNORMAL); | ProcessStartInfo sinfo = new PSI("KTPlot.exe"); Process.Start(sInfo); |
Jump Label | Jump: | No change |
Label Caption | Label2->Caption = AnsiString(charYW); | label2.Text = strYW; |
List Alphabetize | See RE052-RE065 in the App C -- KTVC#TaggedCode.doc file. | |
Lower Case | tolower (strRecord); | textBox1.Text = (textBox1.Text).ToLower(); |
Message Box | MessageBox.Show("Cannot open file."); | |
MessageBox Response | DialogResult dr = MessageBox.Show(); if(dr == DialogResponse.Yes) | |
Open File | int fd; if((fd = open("Filename")) == “1; | FileStream fs; try, then catch. |
Open File | FILE *fp; if((fp = fopen("Filename", "rt")) == NULL) | StreamReader w = new StreamReader("File"); |
OpenFile Dialog | See PL0282-PL0288 in the App C -- KTVC#TaggedCode.doc file. | |
Page Scale | grfx.PageScale = 0.5f; | |
Page Unit | grfx.PageUnit = GraphicsUnit.Document; // 1/300th of an inch. | |
Parsing | D1 = strBlock.Substring(5,5); D2 = strBlock.Substring(7,11); | |
Pen | Pen greenPen = new Pen(Color.Green,2); | |
Record Size | sizeof(Record); | Not used. Receiving location has variable size. |
Rewind | rewind(ff); | Not used |
Round | GainLoss = Decimal.Round(GainLoss,0); // Nothing after decimal point. | |
Simple Sort (Alphabetic) | See RE052-RE065 in the App C -- KTVC#TaggedCode.doc file. | |
String Array Sizing | Not used. Size placed in 'arrayname.Length'. | |
String Concatenation | strcat(charMNRecord, charShortYW); | strYW = strYW + textBox1.text; |
String Copy | strcpy | strYW = textBox1.text; |
String to Decimal | GainLoss = Decimal.Parse(strGainLoss); | |
String to Int | intYear = Convert.ToInt32(strShortYear); | |
String Length | Stringlength = textBox1.Text.Length; | |
Substring | string strShortYear = strTB1.Substring(2,2); | |
Upper Case | toupper(strRecord); | textBox1.Text = (textBox1.Text).ToUpper(); |
While | while(charNGLDummy[dd] != '.') { } | No change |
Write Text to Printer | WriteLine | grfx.DrawString(strRecord, font1, Brushes.Black, 200, 600); |