预期的类,委托,枚举,接口或结构 [英] Expected class,delegate,enum, interface,or struct
本文介绍了预期的类,委托,枚举,接口或结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
错误预期的类,委托,枚举,接口或结构,我无法检测到什么是问题。
代码添加的评论:
Error Expected class, delegate, enum, interface, or struct,i am unable to detect what can be issues.
Code added from comment:
////code with error///
public class 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 -- 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 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 -- 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;
}
}
推荐答案
预期的类,代表,枚举,接口或struct
您没有在命名空间中声明这些元素。
我建议你得到一个关于C#/ ASP.NET基础知识的书。
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.
它实际上可以是任何东西。缺少分号,缺少程序集引用,语法不正确等。无法看到您的代码使得无法提供更具体的帮助。
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.
此消息的最可能原因是您编写的代码应该在类,委托,枚举中,接口或结构直接进入命名空间范围。这通常是由额外的一个右大括号('}')导致你的范围变得有点棘手
请采取以下措施:
The most likely cause of this message is that you have written code that should be within a class, delegate, enum, interface or struct directly into the namespace scope. This is often caused by an extra a closing brace ('}') causing your scoping to go a bit screwy
take the following:
namespace xxxx
{
public class yyyy
{
public method zzzz()
{
//blah
}
public method qqqqq()
{
}
}
}
如果我要加一个额外的}:
if i were to add an extra } :
namespace xxxx
{
public class yyyy
{
public method zzzz()
{
//blah
} // this shouldnt be here
}//this becomes the closing brace of the class rather than the method
public method qqqqq() // this method is now outside the class!!
{
}
}
}
这篇关于预期的类,委托,枚举,接口或结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文