The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Best practice per gli obsolete in un enum

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Adrian Florea

Posts: 206
Nickname: adrian11
Registered: Jul, 2004

Adrian Florea is a .NET developer from Italy
Best practice per gli obsolete in un enum Posted: Jun 29, 2005 11:19 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Adrian Florea.
Original Post: Best practice per gli obsolete in un enum
Feed Title: Web Log di Adrian Florea
Feed URL: /error.aspx?aspxerrorpath=/adrian/Rss.aspx
Feed Description: "You know you've achieved perfection in design, not when you have nothing more to add, but when you have nothing more to take away." Antoine de Saint-Exupery
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Adrian Florea
Latest Posts From Web Log di Adrian Florea

Advertisement

Succede che a volte dovete cambiare i nomi degli elementi in un'enum, per esempio, da ConsoleKey.BackSpace a ConsoleKey.Backspace, oppure da ConsoleKey.SpaceBar a ConsoleKey.Spacebar, utilizzando l'attributo Obsolete. Attenzione all'ordine degli elementi con lo stesso valore! L'elemento obsolete deve essere posizionato dopo l'elemento valido dello stesso valore.

Il seguente snippet:

class Test
{
      static void Main()
      {
            Foo f = (Foo)1;
            System.Console.WriteLine(f);
      }
}

stampa SomeThing a console se l'enum è:

// NO!
public enum Foo
{
      [Obsolete("Use Foo.Something.")]
      SomeThing = 1,
      Something = 1
}

e Something se l'enum è:

// OK!
public enum Foo
{
      Something = 1
      [Obsolete("Use Foo.Something.")]
      SomeThing = 1,
}

Read: Best practice per gli obsolete in un enum

Topic: BizTalk Adapter for SharePoint v2 Previous Topic   Next Topic Topic: WS-I Security End-to-End Sample App

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use