Error Cs1518 Expected Class
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 expected class delegate enum interface or struct c# this site About Us Learn more about Stack Overflow the company Business Learn cs1518 error more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask 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 CS1518: Expected class, delegate, enum, interface, or struct up vote -1 down vote 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 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 answ
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 Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, http://stackoverflow.com/questions/21910568/cs1518-expected-class-delegate-enum-interface-or-struct just like you, helping each other. Join them; it only takes a minute: Sign up Getting CS1518: Expected class, delegate, enum, interface, or struct error up vote 1 down vote favorite I'm new to C# and I'm trying to learn (I've been asking a few questions lately on it - my only programming knowledge is in http://stackoverflow.com/questions/12975155/getting-cs1518-expected-class-delegate-enum-interface-or-struct-error Python, PHP and Javascript). Anyway, I found some examples on the web for how to generate a picklist in C#, and I'm trying to use/modify them to fit my existing code. The results are coming up with an expected class error - but I'm creating a class! Here's my code: private void PeerReview() { MySqlConnection connection; string connStringName = "server=localhost;database=hourtracking;uid=username;password=password"; connection = new MySqlConnection(connStringName); cmd.CommandText = "select name from peer_review_info where active_status=1"; cmd.Connection = connection; connection.Open(); using (SqlDataReader sdr = cmd.ExecuteReader()) { while (sdr.Read()) { ListItem item = new ListItem(); item.Text = sdr["peerrevid"].ToString(); item.Value = sdr["peerrevid"].ToString(); item.Selected = Convert.ToBoolean(sdr["IsSelected"]); chkPeerRev.Items.Add(item); } } connection.Close(); } } } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.PeerReview(); } } c# asp.net mysql class share|improve this question asked Oct 19 '12 at 13:19 Andrew Alexander 2,993145199 Wait, or am I just using a method of a class that does not exist? –Andrew Alexander Oct 19 '12 at 13:20 2 Where do you get thi
SQL Server 2014 Express resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums https://social.msdn.microsoft.com/Forums/en-US/faa1c046-38a8-4d76-a2b5-bac06d790afe/cs1518-expected-class-delegate-enum-interface-or-struct?forum=csharplanguage Blogs Channel 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. https://bytes.com/topic/c-sharp/answers/669488-trying-declare-extern-function Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Answered by: CS1518: Expected class, delegate, enum, interface, or expected class struct Archived Forums V > Visual C# Language Question 0 Sign in to vote I am hoping for some help. I put together this conference manager program but I cant seem to find my error with the class reference. please help. Here is the program. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace error cs1518 expected ConLink { class Program { private const int DELAY = 30; private const int DELAYLONG = 30 * DELAY; static void Main(string[] args) { try { if (Login()) { Console.WriteLine(); SlowString( "Perhaps a game of Global Thermonuclear War?"); Console.Write(">>"); if (Console.ReadLine() != String.Empty) { SlowString("Loading HotelReg 34.234.22"); Console.WriteLine(); Wait(); bool blnOK; do { blnOK = RegGuest(); } while (blnOK); } } } catch (Exception) { Console.WriteLine("Unexpected error!"); } finally { Console.WriteLine(); SlowString("Goodbye."); } } private static void wait() { Thread.Sleep(DELAYLONG); } // Note three overloaded versions of the same procedure. private static void SlowString(String Data) { SlowString(Data, true, DELAY); } private static bool Login() { SlowString( "Attempting Remote Connection. Please wait . . ."); Wait(); SlowString("Connection Successful"); SlowString("HAL System 432.38851.014 is online."); SlowString(String.Format("Today is {0:D}", DateTime.Today)); Wait(); Console.WriteLine(); SlowString("User id: >", false); String strUserId = Console.ReadLine(); if (String.IsNullOrEmpty(strUserId)) return false; else { SlowString("Password: >", false); Console.ReadLine(); // Of course, you might really validate in here... SlowString(String.Format( "Welcome back {0}. I hope you are well.", strUserId)); Sl
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