Chapter 9 Flashcards

1
Q

What are attributes

A

They add declarative programming in program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is meta data

A

It means there is a program and with meta data we are adding additional information for that program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is obsolete attribute

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to apply obsolete attribute

A
[Obsolete] 
public void methodName() {
Console.Writeln("testcase");
}
// Or
[ObsoleteAttribute] 
public void methodName() {
Console.Writeln("testcase");
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is [STAThread]

A

It makes the program thread safe for com and it uses for main

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is command to compile c sharp program on cmd

A

csc FileName.cs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are 2 types of attributes parameters

A
  1. Positional (one, two, three)

2. Named (one=22, two=23, three=48)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the role of DLL import attribute

A

It tells to load Dll file

[DLLImport(“User32.dll”, EntryPoint=”MessageBox”)]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Can we use named and positional parameters together

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is cls

A

Common Language Subsystem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is uint

A

unsigned int

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are enums

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How to declare enum

A
public enum Volume {
Low,
Medium,
High
}
and in class main method, we can call it as:
Volume.Low
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is default type of enum

A

int

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Can we type cast enum default type and if yes then how

A
Yes
public enum Volume : byte {
Low = 1,
Medium,
High
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is operator overloading

A

In c#, we can give new meaning to built in operators like +,-,*

17
Q

What are access modifiers

A
  1. Private (Only members within the same type)
  2. Protected (Only derived types or members of same type)
  3. Internal (Only code with in the same assembly. Can also be code external to object as long as it is in the same assembly)
  4. Protected internal (Either code from derived type or code in the same assembly. Combination of protected or internal)
  5. Public (Any code)
18
Q

What is default type of access modifiers

A

Private

19
Q

What are 2 important types of collection

A
  1. List collection (simple list)

2. Dictionary collection (key value pair list)