2017-02-03 12 views
-1

Ich bin sehr neu in der Codierung, aber ich habe Interesse so beschlossen, eine Klasse an meiner Community College zu nehmen. Ich schließe eine grundlegende Aufgabe ab und erstelle einen Sprachübersetzer für drei Wörter meiner Wahl. Ich habe mein Buch verfolgt, aber immer noch die Fehler bekommen. Ich habe meinen Code und meine Fehler unten kopiert und schätze jede Anleitung.Fehler in C#, Visual Studio

-- using System; 

namespace Language_Translator_Latin 
{ 
partial class Form1 
{ 
    /// <summary> 
    /// Required designer variable. 
    /// </summary> 
    private System.ComponentModel.IContainer components = null; 

    /// <summary> 
    /// Clean up any resources being used. 
    /// </summary> 
    ) 
    { 
     if (disposing && (components != null)) 
     { 
      components.Dispose(); 
     } 
     base.Dispose(disposing); 
    } 

    #region Windows Form Designer generated code 

    /// <summary> 
    /// Required method for Designer support - do not modify 
    /// the contents of this method with the code editor. 
    /// </summary> 
    private void InitializeComponent() 
    { 
     this.button1 = new System.Windows.Forms.Button(); 
     this.button2 = new System.Windows.Forms.Button(); 
     this.button3 = new System.Windows.Forms.Button(); 
     this.label1 = new System.Windows.Forms.Label(); 
     this.label2 = new System.Windows.Forms.Label(); 
     this.SuspendLayout(); 
     // 
     // button1 
     // 
     this.button1.Location = new System.Drawing.Point(21, 112); 
     this.button1.Name = "button1"; 
     this.button1.Size = new System.Drawing.Size(85, 21); 
     this.button1.TabIndex = 0; 
     this.button1.Text = "Hello"; 
     this.button1.UseVisualStyleBackColor = true; 
     // 
     // button2 
     // 
     this.button2.Location = new System.Drawing.Point(149, 112); 
     this.button2.Name = "button2"; 
     this.button2.Size = new System.Drawing.Size(85, 21); 
     this.button2.TabIndex = 1; 
     this.button2.Text = "Happy"; 
     this.button2.UseVisualStyleBackColor = true; 
     // 
     // button3 
     // 
     this.button3.Location = new System.Drawing.Point(288, 112); 
     this.button3.Name = "button3"; 
     this.button3.Size = new System.Drawing.Size(85, 21); 
     this.button3.TabIndex = 2; 
     this.button3.Text = "Good night"; 
     this.button3.UseVisualStyleBackColor = true; 
     // 
     // label1 
     // 
     this.label1.AutoSize = true; 
     this.label1.Location = new System.Drawing.Point(81, 41); 
     this.label1.Name = "label1"; 
     this.label1.Size = new System.Drawing.Size(201, 13); 
     this.label1.TabIndex = 3; 
     this.label1.Text = "Select a word and I will convert it to Latin"; 
     // 
     // label2 
     // 
     this.label2.AutoSize = true; 
     this.label2.Location = new System.Drawing.Point(198, 76); 
     this.label2.Name = "label2"; 
     this.label2.Size = new System.Drawing.Size(35, 13); 
     this.label2.TabIndex = 4; 
     this.label2.Text = "label2"; 
     // 
     // Form1 
     // 
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 
     this.ClientSize = new System.Drawing.Size(431, 164); 
     this.Controls.Add(this.label2); 
     this.Controls.Add(this.label1); 
     this.Controls.Add(this.button3); 
     this.Controls.Add(this.button2); 
     this.Controls.Add(this.button1); 
     this.Name = "Form1"; 
     this.Text = "Form1"; 
     this.ResumeLayout(false); 
     this.PerformLayout(); 

    } 

    #endregion 

    private System.Windows.Forms.Button button1; 
    private System.Windows.Forms.Button button2; 
    private System.Windows.Forms.Button button3; 
    private System.Windows.Forms.Label label1; 
    private System.Windows.Forms.Label label2; 
} 
} 
private void HelloButton_Click(object sender, EventArgs e) 
{ 
translationLabel.Text = "Salve"; 
} 
private void HappyButton_Click(object sender, EventArgs e) 
{ 
translationLabel.Text = "Laeta"; 
} 
private void GoodnightButton_Click(object sender, EventArgs e) 
{ 
translationLabel.Text = "Bonum nox" 

Fehler:

+0

Ihre Frage scheint unvollständig. – brugnner

+0

Sie müssen den gesamten Code posten, damit wir das Problem beheben können. Es scheint, dass Sie etwas Code vermissen. –

+0

Was sind die Klammern in Zeile 7? –

Antwort

0

nicht sicher, welche Fehler Sie bekommen, dass ein Teil Ihrer Frage jetzt leer ist.

Ich sehe einige Probleme mit der Platzierung des "privaten void HelloButton" und nach unten, es scheint außerhalb der Klasse selbst zu sein.

Sie haben zwei Linien, die } } sind

direkt über dem Abschnitt I erwähnt, und es sollte von Ihrem privaten void HelloButton nur seinem} gefolgt. Dann am Ende fehlt dir eine}, plus die Schließung}.

Hier ist etwas näher an was Sie wollen. Ich habe nicht den ganzen Code, also habe ich nur den Endteil aufgeräumt. Sie müssen vorsichtiger sein, wenn Sie die {und} zusammenbringen. Eine andere Sache ist die Platzierung von #endregion, die mit dem automatisierten Code, auf den es sich bezieht, bleiben sollte.

// 
     // Form1 
     // 
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 
     this.ClientSize = new System.Drawing.Size(431, 164); 
     this.Controls.Add(this.label2); 
     this.Controls.Add(this.label1); 
     this.Controls.Add(this.button3); 
     this.Controls.Add(this.button2); 
     this.Controls.Add(this.button1); 
     this.Name = "Form1"; 
     this.Text = "Form1"; 
     this.ResumeLayout(false); 
     this.PerformLayout(); 
    } 
    #endregion 

    private System.Windows.Forms.Button button1; 
    private System.Windows.Forms.Button button2; 
    private System.Windows.Forms.Button button3; 
    private System.Windows.Forms.Label label1; 
    private System.Windows.Forms.Label label2; 

    private void HelloButton_Click(object sender, EventArgs e) 
    { 
     translationLabel.Text = "Salve"; 
    } 
    private void HappyButton_Click(object sender, EventArgs e) 
    { 
     translationLabel.Text = "Laeta"; 
    } 
    private void GoodnightButton_Click(object sender, EventArgs e) 
    { 
     translationLabel.Text = "Bonum nox"; 
    } 
} 

}

+0

Danke Trelly! –