using System;namespace MultiLayer.Model{ [Serializable] public class UserInfo {
[Serializable] 表示注释吗?

解决方案 »

  1.   

    加上属性[Serializable]后,表示类是可以被序列化的.
      

  2.   

    这是C#的属性,你也可以自定义的.要继承Attribute类..很多都是用在调试,编译时的功能...
      

  3.   

    參見
    http://blog.csdn.net/tjvictor/archive/2007/01/25/1492913.aspx
      

  4.   

    不是啊~~~这个是Attribute,老大!
    C#中有两种注释方式
    第一种:
    //你太有才了!
    第二种:
    /*
    下蛋公鸡,
    公鸡中的战斗机。
    Oh Yeah!
    */
      

  5.   

    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 toSpecify which security privileges a class requiresSpecify security privileges to refuse to reduce security riskDeclare capabilities, such as supporting serializationDescribe the assembly by providing a title, description, and copyright noticeAttribute 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: AssemblyTrade("")>// 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: AssemblyTrade("")]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: