我的网址中问号的名称是什么?
http://example.com/foo.aspx?foo=bar
我正在重构,需要命名仅保存该字符串的问号字符的常量。我不确定该变量的最佳名称是什么,因为我从来不知道该问号的正确名称是什么。
我应该为常量命名什么?或者... .NET 中是否有一些东西是更明智的选择(内置的东西,其值已经是问号 - 或者自动为我构建一个查询字符串,给定名称/值对集合)?
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)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
在本文档中,它的字面名称为“问号”(包括连字符)(http://www.ietf.org/rfc/rfc2396.txt -- 向下滚动到 3.2 权限组件)。
我同意这是一个坏名字。散列 (#) 称为“片段标识符”(向下滚动至 4.1)。所以也许它应该被称为“查询标识符”。
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".
在 URI 中,分层部分和查询部分之间的分隔符始终是问号,那么为什么要把它变成一个常数呢?
可能的名称:
QuerySeparator
QueryStartCharacter
QuestionMark
CurlyThingWithDotBelow
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
这个没必要点名吧.NET 有一个 UriBuilder 类,可以帮助您构建您的网址的。查看这篇文章,了解它是如何工作的,并使其更加直观:
http://codeidol.com/csharp/csharpckbk2/Web/Using-the-UriBuilder-Class/
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/
好吧,那个问号只是表明这是一个 GET 请求,后面会发送参数。称其为查询或其他名称,但这似乎是浪费时间,因为您可以安全地对其进行硬编码。对于 GET 请求,它永远不会改变
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
查询字符串标识符?
我不记得看到过这个角色的具体名字。
也许是 QUERYSTRING_ID
Query string identifier?
I don't recall seeing any named specific for the character.
Perhaps QUERYSTRING_ID
它没有正式名称,但您可以将其称为searchpart分隔符(因为它将搜索部分与 URI 的前一部分分开)。
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).
据我在 RFC 3986 中找到的,没有具体的名称。 “
Fragment段分隔符”,仅此而已。As far as I can find in RFC 3986, there is no specific name for that. "
Fragmentsegment separator", nothing more.在 JavaScript 中,它被称为“搜索”
In JavaScript it is called "search"