Chapter 9 Flashcards
What are attributes
They add declarative programming in program
What is meta data
It means there is a program and with meta data we are adding additional information for that program.
What is obsolete attribute
If we want to mark a method that it is obsolete and there is a new method in place of it then we use obsolete attribute.
How to apply obsolete attribute
[Obsolete] public void methodName() { Console.Writeln("testcase"); } // Or [ObsoleteAttribute] public void methodName() { Console.Writeln("testcase"); }
What is [STAThread]
It makes the program thread safe for com and it uses for main
What is command to compile c sharp program on cmd
csc FileName.cs
What are 2 types of attributes parameters
- Positional (one, two, three)
2. Named (one=22, two=23, three=48)
What is the role of DLL import attribute
It tells to load Dll file
[DLLImport(“User32.dll”, EntryPoint=”MessageBox”)]
Can we use named and positional parameters together
Yes
What is cls
Common Language Subsystem
What is uint
unsigned int
What are enums
They are enumerated types and are strongly type. Its example is we want to use digits for four directions norht, east, south and west. It is good for program to use 0 1 2 3 instead of string but this will kill readability. And what will happen if user put 7. Enum comes as a solution and they are handy for it.
How to declare enum
public enum Volume { Low, Medium, High } and in class main method, we can call it as: Volume.Low
What is default type of enum
int
Can we type cast enum default type and if yes then how
Yes public enum Volume : byte { Low = 1, Medium, High }