您的位置:程序门 -> .net技术 -> c#



[serializable] 表示注释吗?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


[serializable] 表示注释吗?[已结贴,结贴人:dgarden]
发表于:2007-03-02 09:38:54 楼主
using   system;

namespace   multilayer.model

{

[serializable]

public   class   userinfo

{


[serializable]   表示注释吗?
发表于:2007-03-02 09:42:201楼 得分:2
不是,属性,表示可序列化
发表于:2007-03-02 09:44:142楼 得分:2
加上属性[serializable]后,表示类是可以被序列化的.
发表于:2007-03-02 10:17:033楼 得分:1
这是c#的属性,你也可以自定义的.要继承attribute类..

很多都是用在调试,编译时的功能...
发表于:2007-03-02 10:22:584楼 得分:2
參見
http://blog.csdn.net/tjvictor/archive/2007/01/25/1492913.aspx
发表于:2007-03-02 10:26:515楼 得分:1
序列化,简单点来说,就是可以把一个类变成一个文件。
发表于:2007-03-02 10:31:126楼 得分:1
不是啊~~~这个是attribute,老大!
c#中有两种注释方式
第一种:
//你太有才了!
第二种:
/*
下蛋公鸡,
公鸡中的战斗机。
oh   yeah!
*/
发表于:2007-03-02 10:37:317楼 得分:1
是attribute
发表于:2007-03-05 14:09:428楼 得分:0
明白了,谢谢:)
发表于:2007-08-03 00:55:169楼 得分:0
what   are   attributes?
attributes   describe   a   type,   method,   or   property   in   a   way   that   can   be   programmatically   queried   using   a   technique   called   reflection.   some   common   uses   for   attributes   are   to

specify   which   security   privileges   a   class   requires

specify   security   privileges   to   refuse   to   reduce   security   risk

declare   capabilities,   such   as   supporting   serialization

describe   the   assembly   by   providing   a   title,   description,   and   copyright   notice

attribute   types   derive   from   the   system.attribute   base   class   and   are   specified   using   <>   or   []   notation.   the   following   code   sample   demonstrates   how   to   add   assembly   attributes:

'   vb   assemblyinfo.vb
<assembly:   assemblytitle( "ch01vb ")>
<assembly:   assemblydescription( "chapter   1   samples ")>
<assembly:   assemblycompany( "microsoft   learning ")>
<assembly:   assemblyproduct( "ch01vb ")>
<assembly:   assemblycopyright( "copyright   &#169;   2006 ")>
<assembly:   assemblytrademark( " ")>

//   c#   -   assemblyinfo.cs
[assembly:   assemblytitle( "ch01cs ")]
[assembly:   assemblydescription( "chapter   1   samples ")]
[assembly:   assemblyconfiguration( " ")]
[assembly:   assemblycompany( "microsoft   learning ")]
[assembly:   assemblyproduct( "ch01cs ")]
[assembly:   assemblycopyright( "copyright   &#169;   2006 ")]
[assembly:   assemblytrademark( " ")]

visual   studio   automatically   creates   some   standard   attributes   for   your   assembly   when   you   create   a   project,   including   a   title,   description,   company,   guide,   and   version.   you   should   edit   these   attributes   for   every   project   you   create   because   the   defaults   do   not   include   important   information   such   as   the   description.

attributes   do   more   than   describe   an   assembly   to   other   developers,   they   can   also   declare   requirements   or   capabilities.   for   example,   to   enable   a   class   to   be   serialized,   you   must   add   the   serializable   attribute,   as   the   following   code   demonstrates:

'   vb
<serializable()>   class   shoppingcartitem
end   class

//   c#
[serializable]
class   shoppingcartitem
{
}


without   the   serializable   attribute,   a   class   is   not   serializable.   similarly,   the   following   code   uses   attributes   to   declare   that   it   needs   to   read   the   c:\boot.ini   file.   because   of   this   attribute,   the   runtime   will   throw   an   exception   prior   to   EXECution   if   it   lacks   the   specified   privilege:



快速检索

热门点击