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 CLSCompliant attribute
Q:

C# program to demonstrate the CLSCompliant attribute

0

C# program to demonstrate the CLSCompliant 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 CLSCompliant attribute is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.

//C# program to demonstrate the 
//CLSCompliant attribute.

using System; 

[assembly:CLSCompliant(true)]   
public class Sample
{ 
    public uint num; 
} 
  
class Program
{ 
    public static void Main(string[] args) 
    { 
        Console.WriteLine("Hello world"); 
    } 
} 

Output:

Compilation succeeded - 1 warning(s)
Hello world

Explanation:

In the above program, we created the two classes Sample and Program. Here, we used the CLSCompliant attribute with Sample class. Here, the declaration of num data member will generate a warning. Because the CLSCompliant attribute is used to generate a warning message when a code element is not CLS compliant.

The Program class contains the Main() method. The Main() method is the entry point for the program. Here, we printed the "Hello world" message 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