【特 性】Attribute
2024-09-30 13:42:34
1 AttributeUsage
[AttributeUsageAttribute(AttributeTargets.All, AllowMultiple = true, Inherited = true)]
class MyNewAttribute : System.Attribute
{
//
}
2 Flags
class Program
{
static void Main(string[] args)
{
Animal animals = Animal.Dog | Animal.Cat;
Console.WriteLine(animals.ToString());
}
}
[Flags]
enum Animal
{
Dog = 0x0001,
Cat = 0x0002,
Duck = 0x0004,
Chicken = 0x0008
}
3 DllImport
[System.Runtime.InteropServices.DllImport("User32.dll")]
public static extern int MessageBox(int hParent, string msg, string caption, int type);
static void Main(string[] args)
{
MessageBox(, "How to use attribute in .NET", "Anytao_net", );
}
4 Serializable
Serializable 特性表明了应用的元素可以被序列化(serializated),序列化和反序列化是另一个 可以深入讨论的话题,在此我们只是提出概念,深入的研究有待以专门的主题来呈现,限于篇幅, 此不赘述。
5 Conditional
Conditional 特性,用于条件编译,在调试时使用。注意:Conditional 不可应用于数据成员和 属性。
还有其他的重要特性,包括:Description、DefaultValue、Category、ReadOnly、Brow erAble 等,有时间可以深入研究。
最新文章
- 操作数数据类型 ntext 对于 max 运算符无效
- connect &; express简介
- 在linux下的firefox中安装flashplayer
- 维护没有源代码,float改成double
- listview默认选择第一项,点击换子项背景图
- 解决Eclipse自己主动补充问题空间
- ubuntu下apache与php配置
- windows 开机自动启动方案
- Git命令集
- day12 python作业:员工信息表
- NFS服务搭建与配置
- 初始if..else 条件语句
- 使用 PowerShell 创建 Azure VM 的自定义映像
- 20155202《网络对抗》Exp8 Web基础
- Java容器Map接口
- 【redis】常用命令
- IIS中User-mode caching引起的Cache-Control不为public的问题
- Android 基于蓝牙的方向控制器
- python:控制鼠标和键盘
- phpize命令在安装AMQP插件是报错phpize:Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF envir的解决方法
热门文章
- Google2015校招在线測试题1----扫雷最少点击次数
- Android抽屉菜单DrawerLayout的实现案例
- go语言笔记——append是内置的函数!!!new是一个函数!!!调试可以使用闭包,本质上是print调试,尼玛!
- [Swift通天遁地]八、媒体与动画-(2)实现视频文件的播放和画中画
- 调取easyui -windows 返回值问题
- 聪明的kk --- 搜索超时
- $CF1141A Game 23$
- flask 中的模板语法 jinja2及render_template的深度用法
- PHP富文本编辑器 之Kindeditor的使用 一
- 本地mongochef连接其他计算机上的数据库认证失败解决方法