有这样的代码:
namespace SdaiBuyWebUI
{
[
DefaultProperty("PageIndex"),
ToolboxData("<{0}:PageControl runat=server></{0}:PageControl>")
]
public class PageControl : WebControl
{
[
Bindable(true),
Category("数据"),
DefaultValue("5"),
Localizable(true),
Description("每页条数")
]
...............
}
.......................
}
究竟这个中括号什么意思啊??谢谢!
namespace SdaiBuyWebUI
{
[
DefaultProperty("PageIndex"),
ToolboxData("<{0}:PageControl runat=server></{0}:PageControl>")
]
public class PageControl : WebControl
{
[
Bindable(true),
Category("数据"),
DefaultValue("5"),
Localizable(true),
Description("每页条数")
]
...............
}
.......................
}
究竟这个中括号什么意思啊??谢谢!
[] 运算符请参见
C# 运算符 | 数组 | 索引器 | unsafe | fixed
方括号 ([]) 用于数组、索引器和属性,也可用于指针。
type []
array [ indexexpr ]
其中:
type
类型。
array
数组。
indexexpr
索引表达式。
备注
数组类型是一种后跟 [] 的类型:
int[] fib; // fib is of type int[], "array of int"
fib = new int[100]; // create a 100-element int array
若要访问数组的一个元素,则用方括号括起所需元素的索引:
fib[0] = fib[1] = 1;
for( int i=2; i<100; ++i ) fib[i] = fib[i-1] + fib[i-2];
如果数组索引超出范围,则会引发异常。
不能重载数组索引运算符;但类型可以定义包含一个或多个参数的索引器和属性。索引器参数括在方括号中(就像数组索引一样),但索引器参数可声明为任何类型(与数组索引不同,数组索引必须为整数)。
例如,.NET Framework 定义一个哈希表类型,该类型将键和任意类型的值关联在一起。
Collections.Hashtable h = new Collections.Hashtable();
h["a"] = 123; // note: using a string as the index
方括号还用于指定属性:
[attribute(AllowMultiple=true)]
public class Attr {
}
可使用方括号来索引指针后面的存储位置(请参见 A.2 指针类型):
unsafe fixed ( int* p = fib ) // p points to fib from earlier example
{
p[0] = p[1] = 1;
for( int i=2; i<100; ++i ) p[i] = p[i-1] + p[i-2];
}
不执行边界检查。
请参见
C# 运算符 | 数组 | 索引器 | unsafe | fixed
Description="Makes a new post to a designated blog. Optionally, "
+ "will publish the blog after making the post.")]
[return: XmlRpcReturnValue(Description="Id of new post")]