rama lakshmi

rama lakshmi

  • NA
  • 4
  • 2.8k

expected class delegate enum interface or struct at void

Mar 16 2016 1:45 AM
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;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void Form1_Load(object sender, EventArgs e)
{
}
public void button1_Click(object sender, EventArgs e)
{
TextWriter tw = new StreamWriter(@"D:\Registration.txt", true);
string name, address, country, pincode, email;
name = textBox1.Text;
address = textBox2.Text;
pincode = textBox3.Text;
email = textBox4.Text;
Decription=textBox5.Text;
textBox5.Multiline = true;
string gender;
if((radioButton1.Checked == true))
{
gender = "Male";
}
else
{
gender = "Female";
}
country = comboBox1.Text;
if(comboBox1.Items.Count==0)
{
comboBox1.Items.Insert(0,"India");
comboBox1.Items.Insert(1,"America");
comboBox1.Items.Insert(2,"SriLanka");
comboBox1.Items.Insert(3,"Dubai");
comboBox1.Text="-select-";
}
else
{
if(string.IsNullOrEmpty("combobox1.selectedvalue"))
{
comboBox1selectedvalue=Convert.ToInt32(comboBox1.SelectedValue);
}
}
if(comboBox1selectedvalue!=null)
{
comboBox1.SelectedValue=comboBox1selectedvalue.Tostring();
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
string language;
if(checkBox1.Checked==true)
{
language="c#";
}
if(checkBox2.Checked==true)
{
language=language+"vb";
}
if(language.Length>0)
{
MessageBox.Show(language+"selected");
}
else
{
MessageBox.Show("not selected");
}
checkBox1.ThreeState=true;
}
}
}
tw.WriteLine("-----------------------");
tw.WriteLine("Details");
tw.WriteLine("name :" + name);
tw.WriteLine("address :" + address);
tw.WriteLine("country :" + comboBox1.SelectedItem.ToString());
tw.WriteLine("pincode :" + pincode);
tw.WriteLine("Email :" + email);
tw.WriteLine("Gender :" + gender);
tw.WriteLine("Language :" + language);
tw.WriteLine("Decription :" + decription);
tw.WriteLine("------------------------");
tw.Close();
Clear();
public void Clear()
{
textBox1.Text = "";
textBox2.Text = "";
comboBox1.Text = "";
textBox3.Text = "";
textBox4.Text = "";
radioButton1.Text = "";
radioButton2.Text = "";
checkBox1.Text = " ";
checkBox2.Text = " ";
textBox5.Text = "";
}
iam getting error: 
1.expected class delegate enum interface or struct at void
2. a namespace cannot directly contain members such as fields or methods how to slove these errors
 
 

Answers (1)