Question
Ok how do I get rid of this one lousy error? Severity Code Description Project File Line Suppression State Error CS0111 Type 'Form1' already defines
Ok how do I get rid of this one lousy error?
Severity Code Description Project File Line Suppression State Error CS0111 Type 'Form1' already defines a member called '.ctor' with the same parameter types.
The codes are as followed:
Form1.cs
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace Week8 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } } }
Form1 designer
namespace Week8 { partial class Form1 { ///
///
#region Windows Form Designer generated code
///
}
#endregion
private System.Windows.Forms.TextBox txtLastName; private System.Windows.Forms.TextBox txtFirstName; private System.Windows.Forms.TextBox txtIDNumber; private System.Windows.Forms.TextBox txtClass; private System.Windows.Forms.TextBox txtGrade; private System.Windows.Forms.Button button1; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label5; private System.Windows.Forms.TextBox textBox6; } }
Program
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace Week8 {
//internal class grades : Form //{
//}
public partial class Form1 : Form {
// Get the location where the data file would be created string fileLoc = Application.StartupPath + "\\Datafile.txt"; /* Constructor of the class to create the GUI of the form */ public Form1() { //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new grades()); InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) { //form the desired string of the text boxes' text string stu_rec = txtLastName.Text + "," + txtFirstName.Text + ":" + txtIDNumber.Text + "" + txtClass.Text + "" + txtGrade.Text; try { //Create an Object of the SteamWriter // class to write the data to the file StreamWriter dat_file = new StreamWriter(fileLoc, true); //Write the data to the file dat_file.WriteLine(stu_rec); //clear the text of all the textbox controls foreach (Control t in this.Controls) { if (t is TextBox) t.Text = ""; } //close the stream dat_file.Close(); } //throw an exception if the exception occurs catch (IOException) { // show the error message MessageBox.Show("Error Occurred. Please try again"); } try { //create a new object of the SteamReader class to read the data from the same file StreamReader read_file = new StreamReader(fileLoc); //variable to read the data string read_rec = ""; //control where the data is to be shown // txtData.Text = ""; //read the data till the end of the file do { //read the data and show it in the text box read_rec = read_file.ReadLine(); // txtData.Text += read_rec + " "; } while (read_rec != null); //close the stream read_file.Close(); } //throw an exception if exception occurs catch (IOException) { //show the message error MessageBox.Show("Problem while reading the file. Please try again."); } }//End class
} // End Namespace }
C Chegg St.dyIuile: 5olt x | Quick Lauren (Chi+Q) He Edt View project Buid Uebug leam Iook lest RI005 Analyze window Hel Soution Explorer Fem1 Search Solution lorerCtrl- using Systes.Collections.Ge%ris; Soliton "Wee 11 preyect) uring Syster Drtngs using Syster Text using Syster kincons Fornsj Asp.corrig uing SyatusT hrwading.aka Form1 p.blic partiol class Fored Fore b1ic Ect) 17 ntine Solution 1 Enu. IA 0Wa'"ings l@our1 Mhaaays l%) 0uld + Inteli,mx Co Dsscrition Fie Linc Suppression St. luunEpla ezm Explorer lype Form lresy dehnes CTpthThe types 0 0111member celle: Actve Weeks E O lype here to searchStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started