C# screen KEY

1. What is the name of the entry point function for all C# programs?

Main()

2. The C# data type int is a synonym for what CLR data type?

System.Int32

3. In C# all primitive data types and user defined data types inherit from what super object?

object

4. How is the C# string class use of == different from all other classes?

When you compare two strings with == you are actually using an overloaded version that compares the characters in the strings instead of the reference values of the two strings. So, if

string s1 = "cat";

string s2 = "cat";

Then the expression s1 == s2 returns true even though s1 and s2 point to two different objects.

5. What encoding does C# use for characters?

Unicode (16-bit)

6. What is the difference between the C# "ref" and "out" keywords when applied to method parameters?

Use "ref" when the parameter/argument has a value but the method changes it. Use "out" when the parameter/argument does not have value and the method supplies it.

7. What are the C# "checked" and "unchecked" keywords used for?

To control whether arithmetic overflow throws an exception (checked) or truncates bits (unchecked).

8. What is the difference between a C# "using" directive and a C/C++ "#include" directive?

A "using" does not add any code to the program it just tells the compiler where to find a namespace. The "include" actually adds code.

9. What is the difference between a C# struct and a C# class in terms of reference types and value types?

A struct is a value object and class is a reference object.

10. Besides "public" and "private", what other two access modifiers can a C# class take?

"protected" and "internal"

11. Why does C# use class destructors far less often that C++?

C# uses the GC (Garbage Collection) mechanism.

12. In C#, are static methods accessed through a class name, an object name, or both?

Class name only.

13. How do you make a C# class abstract (when you want to inherit from it but never implement it directly)?

Use the "abstract" modifier keyword.

14. How do you prevent a C# class from being used as a base class (inherited from)?

Use the "sealed" modifier keyword.

15. C# does not support multiple inheritance. What C# mechanism allows you to have a semblance of multiple inheritance functionality?

Interfaces

16. What are the two kinds of C# properties?

get and set

17. Syntactically, what is the difference between calling a method and a property?

Methods require parentheses, properties do not use parentheses.

18. What is the approximate C# equivalent to a C++ function pointer?

delegate

19. What C# keyword do you use to implement a variable length argument list?

params

20. In C# if you must use pointers, how do you do it?

Use the "unsafe" keyword.

WINFORMS:

  • Which properties on a Windows Forms Control allow you to control it's layout? (Answer: Docking and Anchoring)
  • What method do you call on a Windows Forms Control or drawing object when you are done using it (Answer: Dispose)
  • When will an object be eligable for garbage collection? (Answer: when no other objects are referencing it)

No comments: