A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C# program to demonstrate the Obsolete attribute
Q:

C# program to demonstrate the Obsolete attribute

0

C# program to demonstrate the Obsolete attribute

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

The source code to demonstrate the Obsolete attribute is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.

//C# program to demonstrate the Obsolete attribute.

using System;

class Program
{
    [Obsolete("Absoluted method")]
    public static void SayHello()
    {
        Console.WriteLine("Hello World");
    }
    public static void Main()
    {
        SayHello();
    }
}

Output:

Hello World
Press any key to continue . . .

Explanation:

In the above program, we created a class Program that contains two static methods, here we used the Obsolete attribute to specify the SayHello() method has been obsoleted and then called the method inside the Main() method.

The above code will generate a warning for the obsolete method and it will print "Hello World" on the console screen.

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now