Error Cs1518 Expected Class Delegate Enum Interface Or Struct
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about expected class delegate enum interface or struct c# Stack Overflow the company Business Learn more about hiring developers or posting ads error 1 expected class delegate enum interface or struct with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow
Expected Class Delegate Enum Interface Or Struct Void
is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up CS1518: Expected class, delegate, enum, interface, or struct up vote -1 down vote
Expected Class Delegate Enum Interface Or Struct In Mvc
favorite I am trying to write a new XSLT package. The code that I am using is public virtual string CustomShowInventoryTable(String sProductID, String sVariantID) { StringBuilder results = new StringBuilder(""); if (AppLogic.AppConfigBool("ShowInventoryTable")) { results.Append(AppLogic.GetInventoryTable(ProductID, VariantID, true, ThisCustomer.SkinID, true, false)); } return results.ToString(); } The error I am getting is Compiler Error Message: CS1518: Expected class, delegate, enum, interface, or struct I have tried checking the ( and ) within the how to solve expected class delegate enum interface or struct file but I still get this compiled error. c# xslt share|improve this question edited Feb 20 '14 at 15:00 helderdarocha 14.5k31535 asked Feb 20 '14 at 14:21 Jennifer Larsson 713 1 The compiler should tell you which line, and which column of that line, it's complaining about. Which line is that? (And in this case what's happening before that, since this message usually means your {} braces are not matched properly.) –keshlam Feb 20 '14 at 14:25 Its this linepublic virtual string CustomShowInventoryTable(String sProductID, String sVariantID) –Jennifer Larsson Feb 20 '14 at 14:27 add a comment| 1 Answer 1 active oldest votes up vote 2 down vote accepted I believe that you have a couple of typos in your code: It should be public virtual String, not string. Or maybe string sProductID, string sVariantID instead of String, depending on which language you're working with. AppLogic.GetInventoryTable(ProductID, VariantID - are those variables defined? The ones that your method receive have different names, sProductID and sVariantID... share|improve this answer answered Feb 20 '14 at 14:40 AJPerez 1,55262849 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us
Error 1 Type Or Namespace Definition Or End Of File Expected
Learn more about Stack Overflow the company Business Learn more about hiring developers or cs1518 error posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow identifier expected c# 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 http://stackoverflow.com/questions/21910568/cs1518-expected-class-delegate-enum-interface-or-struct struct” up vote 2 down vote favorite 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 http://stackoverflow.com/questions/16800130/errors-when-compiling-expected-class-delegate-enum-interface-or-struct 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, enum, interface, or struct Expected class, delegate, enum, interface, or struct Expected class, delegate, enum, interface, or struct Expected class, delegate, enum, interface, or struct Expected class, delegate, enum, interface, or struct Expected class, delegate, enum, interface, or struct Type or namespace definition, or end-of-file expected Expected class, delegate, enum, interface, or struct What can I do about this? c# compiler-errors share|improve this question edited May 28 '13 at 19:49 CodeCaster 76.4k982134 asked May 28 '13 at 19:41 user2429934 11112 add a comment| 4 Answers 4 active oldest votes up vote 12 down vote The email_send() method is outside of the class declaration. It's still inside the namespace, but you must also place it inside the class. Additionally, at no point i
Class1 { private CardType _cardTypes; } public bool IsValidCardType(string cardNumber) { // AMEX -- 34 or 37 -- 15 length if ((Regex.IsMatch(cardNumber, "^(34|37)")) && ((_cardTypes & CardType.Amex) != 0)) return (15 == cardNumber.Length); // MasterCard -- http://www.codeproject.com/Questions/249915/Expected-class-delegate-enum-interface-or-struct?display=Print 51 through 55 -- 16 length else if ((Regex.IsMatch(cardNumber, "^(51|52|53|54|55)")) && ((_cardTypes & CardType.MasterCard) https://bytes.com/topic/c-sharp/answers/669488-trying-declare-extern-function != 0)) return (16 == cardNumber.Length); // VISA -- 4 -- 13 and 16 length else if ((Regex.IsMatch(cardNumber, "^(4)")) && ((_cardTypes & CardType.VISA) != 0)) return (13 == cardNumber.Length || 16 == cardNumber.Length); // Diners Club -- 300-305, 36 or 38 -- 14 length else if ((Regex.IsMatch(cardNumber, "^(300|301|302|303|304|305|36|38)")) && ((_cardTypes & CardType.DinersClub) != 0)) return (14 expected class == cardNumber.Length); // enRoute -- 2014,2149 -- 15 length else if ((Regex.IsMatch(cardNumber, "^(2014|2149)")) && ((_cardTypes & CardType.DinersClub) != 0)) return (15 == cardNumber.Length); // Discover -- 6011 -- 16 length else if ((Regex.IsMatch(cardNumber, "^(6011)")) && ((_cardTypes & CardType.Discover) != 0)) return (16 == cardNumber.Length); // JCB -- 3 -- 16 length else if ((Regex.IsMatch(cardNumber, "^(3)")) && ((_cardTypes & CardType.JCB) != 0)) return (16 == cardNumber.Length); // JCB -- expected class delegate 2131, 1800 -- 15 length else if ((Regex.IsMatch(cardNumber, "^(2131|1800)")) && ((_cardTypes & CardType.JCB) != 0)) return (15 == cardNumber.Length); else { // Card type wasn't recognised, provided Unknown is in the CardTypes property, then // return true, otherwise return false. if ((_cardTypes & CardType.Unknown) != 0) return true; else return false; } } Posted 5-Sep-11 2:48am raj_sagoo129 Updated 5-Sep-11 3:25am Mika Wendelius322.2K v2 Comments Mika Wendelius 5-Sep-11 8:50am Could you post the code giving the error... raj_sagoo 5-Sep-11 9:23am code moved to the question 5 solutions Top Rated Most Recent Rate this: Please Sign up or sign in to vote. Solution 3 Accept Solution Reject Solution It could literally be anything. A missing semi-colon, a missing assembly reference, incorrect syntax, and other things. Not being able to see your code makes it impossible to provide more specific assistance. Permalink Posted 5-Sep-11 3:07am John Simmons / outlaw programmer584.4K Rate this: Please Sign up or sign in to vote. Solution 1 Accept Solution Reject Solution Expected class, delegate, enum, interface, or struct You didn't declare of of these elements in your namespace. I suggest you get a book on C#/ASP.NET basics. Permalink Posted 5-Sep-11 2:52am phil.o86.4K Comments Md. Marufuzzaman 5-Sep-11 9:03am I agreed with phil :) Rate this:
your question and get tips & solutions from a community of 418,509 IT Pros & Developers. It's quick & easy. Trying to declare an extern function P: n/a =?Utf-8?B?UmljaGFyZEBub3NwYW0ubm9zcGFt?= I'm trying to declare CreateFile as an extern from the dll like so: .... using System.Runtime.InteropServices; [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError=true)] internal static extern IntPtr CreateFile( String filename, UInt32 desiredAccess, UInt32 shareMode, IntPtr attributes, // Really, this is the SECURITY_ATTRIBUTES pointer UInt32 creationDisposition, UInt32 flagsAndAttributes, IntPtr templateFile); namespace CsharpPipes { .... I get an error on the "IntPtr" that says: error CS1518: Expected class, delegate, enum, interface, or struct with F1 help text of: A declaration was found that is not supported in a namespace. Inside a namespace, the compiler accepts only classes, structs, enums, interfaces, namespaces, and delegates. I assumed my declaration was outside a namespace(?) What's the proper syntax to declare CreateFile? Thanks in advance. Richard Jun 27 '07 #1 Post Reply Share this Question 4 Replies P: n/a Jon Skeet [C# MVP] On Jun 27, 3:46 pm, Rich...@nospam.nospam