Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does ASP.net use square brackets

I'm coming from classic ASP and I did:

myVar = request.querystring("ID")
response.redirect("lol.asp");

And in .net it is:

myVar = Request.Querystring["ID"];
Response.Redirect("lol.aspx");

When are square brackets used over round ones? What do they signify? I'm sort of understanding it at the moment to represent an index?

like image 860
Tom Gullen Avatar asked May 09 '26 22:05

Tom Gullen


1 Answers

Because ASP Classic is Visual Basic Script, which derives from Visual Basic syntax.

If you'd like to use ASP.NET with "round brackets", just switch to VB.NET in ASP.NET's code-behind.

"Round" or "square" brackets are an arbitrary, conventional syntax decision in VB.NET and C#.

UPDATE: I forgot to mention ASP Classic supports JScript too, so ASP classic with JScript would access to array indexes and, mainly indexers, with "square brackets". But it seems that question's author worked with ASP/VBScript :)

like image 126
Matías Fidemraizer Avatar answered May 11 '26 10:05

Matías Fidemraizer