Davis Dimitriov
Davis Dimitriov

Reputation: 4257

ASMX HTTP Get Parameter is a C# Keyword

I use asp.net 2 and need to consume a 3rd party HTTP GET call that includes a parameter named interface

I have created an asmx file and have a function like

[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public void Test(string interface)
{

}   

However, this is a compile error because interface is a C# keyword and so it won't let me create a variable named that.

Is there a way around this problem?

Upvotes: 4

Views: 288

Answers (1)

dmck
dmck

Reputation: 7861

Append interface with the @ symbol

[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public void Test(string @interface)

However this should only be done when absolutely necessary, and should be avoided if at all possible.

Upvotes: 6

Related Questions