Home > expected class > c# error 2 expected class delegate enum interface or struct

C# Error 2 Expected Class Delegate Enum Interface Or Struct

Contents

here for a quick overview of the site Help error 1 expected class delegate enum interface or struct Center Detailed answers to any questions you might have Meta expected class delegate enum interface or struct (cs1518) Discuss the workings and policies of this site About Us Learn more about Stack

Expected Class Delegate Enum Interface Or Struct Void

Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask

How To Solve Expected Class Delegate Enum Interface Or Struct

Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Errors when compiling: “Expected class, delegate, enum, interface, or struct” up vote 2 down vote favorite expected class delegate enum interface or struct in mvc What is wrong with this code? This program is meant to copy a file and email it to a email address, but it doesn't. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Net; using System.Net.Mail; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { } } public void email_send() { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress("your mail@gmail.com"); mail.To.Add("to_mail@gmail.com"); mail.Subject = "Test Mail - 1"; mail.Body = "mail with attachment"; System.Net.Mail.Attachment attachment; attachment = new System.Net.Mail.Attachment("c:/textfile.txt"); mail.Attachments.Add(attachment); SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("your mail@gmail.com", "your password"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); } } This shows the following compiler errors: Expected class, delegate, enu

C# Visual Studio Languages , .NET Framework > Visual C# Question 0 Sign in to vote Hi,I'm new to C#. Im getting

Error 1 Type Or Namespace Definition, Or End-of-file Expected

an "expected class, delegate, enum, interface or struct" error when compling infopath C# identifier expected c# code from Microsoft Submitting Data from InfoPath to a SharePoint list http://msdn.microsoft.com/en-us/library/cc162745.aspx. I pasted the code directy from their site. Can anyone help me out?Thanks,PaulThe error ocurrs on first line of the following code:

private void ClearEnteredValues(XPathNavigator xnDoc) { try { // Get a reference to the form's XmlNamespaceManager http://stackoverflow.com/questions/16800130/errors-when-compiling-expected-class-delegate-enum-interface-or-struct object. XmlNamespaceManager ns = this.NamespaceManager; // Create an XPathNodeIterator object to get a count of the // rows in the repeating table used to add new Contacts. XPathNodeIterator xi = xnDoc.Select( "/my:myFields/my:gpContacts/my:gpContact", ns); int rowCount = xi.Count; if (rowCount > 0) { // Get the first and last rows (nodes) in the // repeating table. XPathNavigator firstNode = xnDoc.SelectSingleNode( https://social.msdn.microsoft.com/Forums/vstudio/en-US/b30b30e8-9e59-4e14-8082-4e647da01303/expected-class-delegate-enum-interface-or-struct-error-c?forum=csharpgeneral "/my:myFields/my:gpContacts/my:gpContact[1]", ns); XPathNavigator lastNode = xnDoc.SelectSingleNode( "/my:myFields/my:gpContacts/my:gpContact[" + rowCount + "]", ns); // Delete the existing nodes using the DeleteRange method. firstNode.DeleteRange(lastNode); } // Clear the check box. xnDoc.SelectSingleNode( "/my:myFields/my:AddContacts", ns).SetValue("false"); } catch (Exception ex) { MessageBox.Show("The following error occurred: " + ex.Message); throw; } } Monday, March 02, 2009 5:18 PM Reply | Quote Answers 0 Sign in to vote Hello,Read this :http://www.ironspeed.com/Designer/5.2.1/WebHelp/Part_VI/Error_CS1518_Expected_class_delegate_enum_interface_or.htmYou probably will get some hints from it.CheersBinze Marked as answer by Bin-ze Zhao Friday, March 06, 2009 2:56 AM Wednesday, March 04, 2009 8:41 AM Reply | Quote All replies 4 Sign in to vote Read up on some tutorials before you start copying and pasting code, make sure you understand it. You haven't posted your whole file (or maybe you have) but it looks like you're defining a method with no class. All methods must be inside a class: namespace MyNamespace   {       public class MyClass       {           private void ClearEnteredValues(....etc....) { } // Your code here       }   }  Proposed as answer by msm44 Thursday, March 04, 2010 10:36 AM Monday, March 02, 2009 5:37 PM R

Tips/Tricks Top Articles Beginner Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article Competition Submit an article or tip Post your Blog quick answersQ&A Ask a Question View Unanswered http://www.codeproject.com/Questions/278599/Error-Expected-class-delegate-enum-interface-or-st Questions View All Questions... C# questions Linux questions ASP.NET questions SQL questions VB.NET https://www.daniweb.com/programming/software-development/threads/385493/expected-class-delegate-enum-code-issue questions discussionsforums All Message Boards... Application Lifecycle> Running a Business Sales / Marketing Collaboration / Beta Testing Work Issues Design and Architecture ASP.NET JavaScript C / C++ / MFC> ATL / WTL / STL Managed C++/CLI C# Free Tools Objective-C and Swift Database Hardware & Devices> System Admin Hosting and Servers expected class Java .NET Framework Android iOS Mobile SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions Spam and Abuse Watch features Competitions News The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research Library CodeProject Stuff communitylounge Who's Who Most Valuable Professionals The Lounge   The Insider News The Weird & The Wonderful The Soapbox Press Releases Non-English expected class delegate Language > General Indian Topics General Chinese Topics help What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Ask a Question All Questions All Unanswered FAQ Error Expected class, delegate, enum, interface, or struct Rate this: Please Sign up or sign in to vote. See more: C# Why this error is giving during run the programme error - Expected class, delegate, enum, interface, or struct My code is given below <%@ Page Language="C#" EnableSessionState="False" EnableViewState="False" Trace="False" Debug="True"%> <%@ Import Namespace="System.Configuration" %> <%@ Import Namespace="System.Web" %> <%@ Import Namespace="System.Web.Security" %> <%@ Import Namespace="System.Web.UI" %> <%@ Import Namespace="System.Web.UI.WebControls" %> <%@ Import Namespace="System.Web.UI.HtmlControls" %> <%@ Import Namespace="System.Net.Mail" %>

Enter Email Name Subject Click to send



 

© Copyright 2019|winbytes.org.