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

Error 2 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 Stack Overflow the company Business Learn expected class delegate enum interface or struct in mvc more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags

List Expected Class Delegate Enum Interface Or Struct

Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, expected class delegate enum interface or struct error in c# helping each other. Join them; it only takes a minute: Sign up “Expected class, delegate, enum, interface or struct” error on public static string MyFunc(). What's an alternative to “string”? up vote 11 down vote favorite 3 I'm error 1 expected class delegate enum interface or struct error in c# getting an error when I attempt to use the following static function. Error: Expected class, delegate, enum, interface, or struct Function (and class): namespace MyNamespace { public class MyClass { // Some other static methods that use Classes, delegates, enums, interfaces, or structs public static string MyFunc(string myVar){ string myText = myVar; //Do some stuff with myText and myVar return myText; } } } This is causing the compiler to angrily (in red) underline the string

Expected Class Delegate Enum Interface Or Struct (cs1518)

part of public static string. So, I assume this means string is not a class, delegate, enum, interface, or struct. What can I use instead of string to return a string or string-like object? There doesn't appear to be a String (capital S) class in C#. Edit: Bracket mis-match with some commented code - the above code works correctly, my actual mis-matched code didn't. Thanks! c# compiler-errors static-methods share|improve this question edited May 14 '14 at 13:26 Irvin Dominin 22.9k64068 asked Jan 28 '11 at 2:14 Peach 74911222 add a comment| 2 Answers 2 active oldest votes up vote 21 down vote accepted You need to put the method definition into a class/struct definition. Method definitions can't appear outside those. share|improve this answer answered Jan 28 '11 at 2:15 Femaref 48.2k391132 (I thought) It was. Updating code to include those details... –Peach Jan 28 '11 at 2:17 4 And I'm quite sure it isn't, at least I didn't encounter this particular compiler error with any other cause. Check your braces, that could be a reason as well. –Femaref Jan 28 '11 at 2:19 It was the braces, good catch! –Peach Jan 28 '11 at 2:22 add a comment| up vote 3 down vote There is a capital S String in C#/.Net - System.String. But that is not your problem. @Femaref got i

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 expected class delegate enum interface or struct void about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges how to solve expected class delegate enum interface or struct Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each

Type Or Namespace Definition Or End-of-file Expected

other. Join them; it only takes a minute: Sign up Expected class, delegate, enum, interface, or struct error [closed] up vote 0 down vote favorite I'm trying to get this code out for display but its giving me this http://stackoverflow.com/questions/4824194/expected-class-delegate-enum-interface-or-struct-error-on-public-static-str error. Is anyone able to help? Hints and suggestions will be good enough as long as I know where I went wrong. public ObservableCollection Data = new ObservableCollection() { new PData() { title = "slice #1", value = 30 }, new PData() { title = "slice #2", value = 60 }, new PData() { title = "slice #3", value = 40 }, new PData() { title = "slice #4", value = 10 }, }; private void PhoneApplicationPage_Loaded(object http://stackoverflow.com/questions/26154792/expected-class-delegate-enum-interface-or-struct-error sender, RoutedEventArgs e) { pie1.DataSource = Data; } public class PData { public string title { get; set; } public double value { get; set; } } c# windows-phone-8 delegates share|improve this question asked Oct 2 '14 at 5:11 JC TAN 15 closed as off-topic by Pierre-Luc Pineault, Albireo, EdChum, greg-449, Hatem Alimam Oct 2 '14 at 8:56 This question appears to be off-topic. The users who voted to close gave this specific reason:"This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Pierre-Luc Pineault, Albireo, EdChum, greg-449If this question can be reworded to fit the rules in the help center, please edit the question. 2 Your method is not enclosed in a class. Unless there's more code you are not showing. –Pierre-Luc Pineault Oct 2 '14 at 5:18 check this stackoverflow.com/questions/4824194/… –Nitin Varpe Oct 2 '14 at 5:24 add a comment| 2 Answers 2 active oldest votes up vote 1 down vote accepted This error typically means that you have the wrong number of brackets { or } somewhere in your code, or that (part of?) your code i

Class1 { private CardType _cardTypes; } public bool IsValidCardType(string cardNumber) { // AMEX -- 34 or http://www.codeproject.com/Questions/249915/Expected-class-delegate-enum-interface-or-struct?display=Print 37 -- 15 length if ((Regex.IsMatch(cardNumber, "^(34|37)")) && ((_cardTypes & CardType.Amex) != 0)) return (15 == cardNumber.Length); // MasterCard -- 51 through 55 -- 16 length else if ((Regex.IsMatch(cardNumber, "^(51|52|53|54|55)")) && ((_cardTypes & CardType.MasterCard) != 0)) return (16 == cardNumber.Length); // VISA -- 4 -- 13 and 16 expected class 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 == cardNumber.Length); // enRoute -- 2014,2149 -- expected class delegate 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 -- 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.1K 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 th

 

Related content

c# error 2 expected class delegate enum interface or struct

C Error Expected Class Delegate Enum Interface Or Struct table id toc tbody tr td div id toctitle Contents div ul li a href Expected Class Delegate Enum Interface Or Struct Void a li li a href How To Solve Expected Class Delegate Enum Interface Or Struct a li li a href Error Type Or Namespace Definition Or End-of-file Expected a li ul td tr tbody table p here for relatedl a quick overview of the site Help error expected class delegate enum interface or struct Center Detailed answers to any questions you might have Meta expected class delegate enum

c# error cs1518 expected class delegate enum interface or struct

C Error Cs Expected Class Delegate Enum Interface Or Struct table id toc tbody tr td div id toctitle Contents div ul li a href How To Solve Expected Class Delegate Enum Interface Or Struct a li li a href Error Type Or Namespace Definition Or End Of File Expected a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you relatedl might have Meta Discuss the workings and policies of error expected class delegate enum interface or struct c this site About Us Learn more about

compiler error message cs1518

Compiler Error Message Cs table id toc tbody tr td div id toctitle Contents div ul li a href C Cs a li li a href Expected Class Delegate Enum Interface Or Struct C a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to relatedl any questions you might have Meta Discuss the workings p h id C Cs p and policies of this site About Us Learn more about Stack Overflow error cs expected class delegate enum interface or struct the company Business Learn more about hiring developers

error 1 expected class delegate enum interface or struct

Error Expected Class Delegate Enum Interface Or Struct table id toc tbody tr td div id toctitle Contents div ul li a href Expected Class Delegate Enum Interface Or Struct In Mvc a li li a href Expected Class Delegate Enum Interface Or Struct cs a li li a href How To Solve Expected Class Delegate Enum Interface Or Struct a li ul td tr tbody table p 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 relatedl more

error conversion to inaccessible base class is not allowed

Error Conversion To Inaccessible Base Class Is Not Allowed table id toc tbody tr td div id toctitle Contents div ul li a href Expected Class Name Before Token Inheritance a li li a href Can Protected Class Be Inherited a li li a href C Public Inheritance Private Members a li li a href C Public Vs Private Vs Protected a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any relatedl questions you might have Meta Discuss the workings and expected class member or base class name

error cs1518 expected class

Error Cs Expected Class p here for a quick overview of the site Help Center Detailed answers to any questions you relatedl 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 cs 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 million programmers just like you helping each other Join them it only takes a

error cs1518 expected class delegate enum interface or struct

Error Cs Expected Class Delegate Enum Interface Or Struct table id toc tbody tr td div id toctitle Contents div ul li a href Expected Class Delegate Enum Interface Or Struct Void a li li a href Expected Class Delegate Enum Interface Or Struct In Mvc a li li a href Error Type Or Namespace Definition Or End Of File Expected a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings relatedl and policies of this site About Us Learn

error expected either a definition for a tag name

Error Expected Either A Definition For A Tag Name table id toc tbody tr td div id toctitle Contents div ul li a href Expected Class Name C a li li a href Expected Class Name Before Token Qt a li li a href Base Class Has Incomplete Type a li li a href Undefined Reference To Vtable a li ul td tr tbody table p p p basic information about a student and their test relatedl grades I need to have the user determine invalid use of incomplete type c the number of structures to be defined I know

expected class delegate enum interface or struct error

Expected Class Delegate Enum Interface Or Struct Error table id toc tbody tr td div id toctitle Contents div ul li a href Expected Class Delegate Enum Interface Or Struct Void a li li a href How To Solve Expected Class Delegate Enum Interface Or Struct a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the relatedl workings and policies of this site About Us Learn more expected class delegate enum interface or struct in mvc about Stack Overflow the company

inline script error expected class delegate enum interface or struct

Inline Script Error Expected Class Delegate Enum Interface Or Struct table id toc tbody tr td div id toctitle Contents div ul li a href Expected Class Delegate Enum Interface Or Struct In Mvc a li li a href Cs Expected Class Delegate Enum Interface Or Struct a li li a href Identifier Expected C a li li a href C Enum a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed relatedl answers to any questions you might have Meta expected class delegate enum interface or struct void Discuss the