<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FAttribute%2FAttribute</id>
		<title>Csharp/CSharp Tutorial/Attribute/Attribute - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FAttribute%2FAttribute"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Attribute/Attribute&amp;action=history"/>
		<updated>2026-05-01T04:43:11Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Attribute/Attribute&amp;diff=5153&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Attribute/Attribute&amp;diff=5153&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:53Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Attribute/Attribute&amp;diff=5154&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Attribute/Attribute&amp;diff=5154&amp;oldid=prev"/>
				<updated>2010-05-26T12:14:29Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Assembly-Level Attributes==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;Attribute                                      Meaning in Life&lt;br /&gt;
AssemblyCompanyAttribute                       basic company information&lt;br /&gt;
AssemblyCopyrightAttribute                     any copyright information&lt;br /&gt;
AssemblyCultureAttribute                       information on cultures or languages&lt;br /&gt;
AssemblyDescriptionAttribute                   a description of the product&lt;br /&gt;
AssemblyKeyFileAttribute                       the name of the file containing the key pair&lt;br /&gt;
AssemblyOperatingSystemAttribute               operating system&lt;br /&gt;
AssemblyProcessorAttribute                     processors to support&lt;br /&gt;
AssemblyProductAttribute                       Provides product information&lt;br /&gt;
AssemblyTrademarkAttribute                     Provides trademark information&lt;br /&gt;
AssemblyVersionAttribute                       assembly&amp;quot;s version information, in the format &amp;lt;major.minor.build.revision&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Custom Attributes==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
    [AttributeUsage(AttributeTargets.Class |&lt;br /&gt;
                    AttributeTargets.Constructor |&lt;br /&gt;
                    AttributeTargets.Field |&lt;br /&gt;
                    AttributeTargets.Method |&lt;br /&gt;
                    AttributeTargets.Property,&lt;br /&gt;
                    AllowMultiple = true)]&lt;br /&gt;
    public class BugFixAttribute : System.Attribute&lt;br /&gt;
    {&lt;br /&gt;
        public int      BugID;&lt;br /&gt;
        public string   Date;&lt;br /&gt;
        public string   Programmer;&lt;br /&gt;
        public string   Comment;&lt;br /&gt;
        public BugFixAttribute(int bugID,string programmer,string date){&lt;br /&gt;
            this.BugID = bugID;&lt;br /&gt;
            this.Programmer = programmer;&lt;br /&gt;
            this.Date = date;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    [BugFixAttribute(1, &amp;quot;B&amp;quot;, &amp;quot;01/04/05&amp;quot;,Comment = &amp;quot;value&amp;quot;)]&lt;br /&gt;
    public class MyMath&lt;br /&gt;
    {&lt;br /&gt;
        public double DoFunc1(double param1)&lt;br /&gt;
        {&lt;br /&gt;
            return param1 + DoFunc2(param1);&lt;br /&gt;
        }&lt;br /&gt;
        public double DoFunc2(double param1)&lt;br /&gt;
        {&lt;br /&gt;
            return param1 / 3;&lt;br /&gt;
        }&lt;br /&gt;
    }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Providing an Attribute Constructor==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
public class CommandLineSwitchAliasAttribute : Attribute&lt;br /&gt;
{&lt;br /&gt;
   public CommandLineSwitchAliasAttribute(string alias)&lt;br /&gt;
   {&lt;br /&gt;
       Alias = alias;&lt;br /&gt;
   }&lt;br /&gt;
   public string Alias&lt;br /&gt;
   {&lt;br /&gt;
      get { return _Alias; }&lt;br /&gt;
      set { _Alias = value; }&lt;br /&gt;
  }&lt;br /&gt;
  private string _Alias;&lt;br /&gt;
}&lt;br /&gt;
class CommandLineInfo&lt;br /&gt;
{&lt;br /&gt;
  [CommandLineSwitchAliasAttribute(&amp;quot;?&amp;quot;)]&lt;br /&gt;
  public bool Help&lt;br /&gt;
  {&lt;br /&gt;
      get { return _Help; }&lt;br /&gt;
      set { _Help = value; }&lt;br /&gt;
  }&lt;br /&gt;
  private bool _Help;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Retrieving a Specific Attribute and Checking Its Initialization==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Reflection;&lt;br /&gt;
public class CommandLineSwitchAliasAttribute : Attribute&lt;br /&gt;
{&lt;br /&gt;
    public CommandLineSwitchAliasAttribute(string alias)&lt;br /&gt;
    {&lt;br /&gt;
        Alias = alias;&lt;br /&gt;
    }&lt;br /&gt;
    public string Alias&lt;br /&gt;
    {&lt;br /&gt;
        get { return _Alias; }&lt;br /&gt;
        set { _Alias = value; }&lt;br /&gt;
    }&lt;br /&gt;
    private string _Alias;&lt;br /&gt;
}&lt;br /&gt;
class CommandLineInfo&lt;br /&gt;
{&lt;br /&gt;
    [CommandLineSwitchAliasAttribute(&amp;quot;?&amp;quot;)]&lt;br /&gt;
    public bool Help&lt;br /&gt;
    {&lt;br /&gt;
        get { return _Help; }&lt;br /&gt;
        set { _Help = value; }&lt;br /&gt;
    }&lt;br /&gt;
    private bool _Help;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
    static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        PropertyInfo property = typeof(CommandLineInfo).GetProperty(&amp;quot;Help&amp;quot;);&lt;br /&gt;
        CommandLineSwitchAliasAttribute attribute = (CommandLineSwitchAliasAttribute)property.GetCustomAttributes(typeof(CommandLineSwitchAliasAttribute), false)[0];&lt;br /&gt;
        if (attribute.Alias == &amp;quot;?&amp;quot;)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;Help(?)&amp;quot;);&lt;br /&gt;
        };&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Saving a Document Using System.SerializableAttribute==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Runtime.Serialization.Formatters.Binary;&lt;br /&gt;
class Program&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
      Stream stream;&lt;br /&gt;
      Document documentBefore = new Document();&lt;br /&gt;
      documentBefore.Title =&amp;quot;test&amp;quot;;&lt;br /&gt;
      Document documentAfter;&lt;br /&gt;
      using (stream = File.Open(documentBefore.Title + &amp;quot;.bin&amp;quot;, FileMode.Create))&lt;br /&gt;
      {&lt;br /&gt;
          BinaryFormatter formatter = new BinaryFormatter();&lt;br /&gt;
          formatter.Serialize(stream, documentBefore);&lt;br /&gt;
      }&lt;br /&gt;
      using (stream = File.Open(documentBefore.Title + &amp;quot;.bin&amp;quot;, FileMode.Open))&lt;br /&gt;
      {&lt;br /&gt;
          BinaryFormatter formatter = new BinaryFormatter();&lt;br /&gt;
          documentAfter = (Document)formatter.Deserialize(stream);&lt;br /&gt;
      }&lt;br /&gt;
      Console.WriteLine(documentAfter.Title);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
[Serializable]&lt;br /&gt;
class Document&lt;br /&gt;
{&lt;br /&gt;
  public string Title = null;&lt;br /&gt;
  public string Data = null;&lt;br /&gt;
  [NonSerialized]&lt;br /&gt;
  public long _WindowHandle = 0;&lt;br /&gt;
  class Image&lt;br /&gt;
  {&lt;br /&gt;
  }&lt;br /&gt;
  [NonSerialized]&lt;br /&gt;
                            private Image Picture = new Image();&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use Attributes to mark a method==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;You can add declarative information to a program by using an attribute.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;An attribute defines additional information that is associated with a class, structure, method, and so on.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;An attribute is supported by a class that inherits System.Attribute.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;All attribute classes must be subclasses of System.Attribute.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;This built-in attribute AttributeUsage specifies the types of items to which the attribute can be applied.&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System.Diagnostics;&lt;br /&gt;
&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
    [Conditional(&amp;quot;DEBUG&amp;quot;)]&lt;br /&gt;
    public void Validate()&lt;br /&gt;
    {&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;C# defines three built-in attributes:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;AttributeUsage,&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Conditional,&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Obsolete.&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>