http://example.com/foo.aspx?foo=bar
I'm refactoring and need to name the constant which will hold only the question mark character of this string. I'm not sure what best to name the variable, as I've never known what the proper name of that question mark was.
What should I name the constant? Or... is there something in .NET that's the wiser choice here (something built-in whose value is already that question mark -- or that builds a querystring for me automatically given a name/value pair collection)?
In this document, it's literally called the "question-mark" (hyphen included) (http://www.ietf.org/rfc/rfc2396.txt -- scroll down to 3.2 Authority Component).
I agree it's a bad name. The hash (#) is called the "Fragment Identifier" (scroll down to 4.1). So maybe it should be called the "Query Identifier".
In URIs the separator between hierarchical and query part always is a question mark, so why pull it into a constant?
Possible names:
QuerySeparator
QueryStartCharacter
QuestionMark
CurlyThingWithDotBelow
There's no need to name this. .NET has a UriBuilder class that can assist you in building your URL's. Check this article to see how it works and to make it a little more intuitive:
http://codeidol.com/csharp/csharpckbk2/Web/Using-the-UriBuilder-Class/
Well, that question mark just indicates that it was a GET request and the parameters sent follow. Call it query or something, but it seems a waste of time since you can safely hard code that in. It will never change for a GET request
Query string identifier? I don't recall seeing any named specific for the character.
Perhaps QUERYSTRING_ID
It doesn't have an official name, but you could call it searchpart seperator (since it separates the searchpart from the previous part of the URI).
As far as I can find in RFC 3986, there is no specific name for that. "Fragment segment separator", nothing more.
In JavaScript it is called "search"
精彩评论