/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/csharp/language-reference/attributes/snippets/ObsoleteExample.cs
49 строк
912 B
Bill Wagner
first draft of nameof updates (#29549)
15 июн 2022, 00:43
Не верифицирован
15 июн 2022, 00:43
86ba43a
Код
Авторство
О чём код?
// <Snippet1> namespace AttributeExamples { [Obsolete("use class B")] public class A { public void Method() { } } public class B { [Obsolete("use NewMethod", true)] public void OldMethod() { } public void NewMethod() { } } public static class ObsoleteProgram { public static void Main() { // Generates 2 warnings: A a = new A(); // Generate no errors or warnings: B b = new B(); b.NewMethod(); // Generates an error, compilation fails. // b.OldMethod(); } } } // </Snippet1> namespace ExampleConstantInterpolation { // <Snippet2> public class B { [Obsolete($"use {nameof(NewMethod)} instead", true)] public void OldMethod() { } public void NewMethod() { } } // </Snippet2> }