C# Flashcards
What is the CLR
Common Language Runtime
What does the C# compiler do?
It takes the C# code and transforms it into Microsoft Intermediate Language. If there are multiple files, it will produce a single executable or library. (And produce an executable?)
What is MISL/what does it do?
Microsoft Intermediate Language. MISL Defines instructions for the CLR
What does the CLR do?
Reads the MISL (Microsoft Intermediate Language) instructions and transforms intro instructions that the CPU on your machine will understand. (Native instructions)
What are native instructions?
Instructions that work on the real hardware where the program is running.
Is C# a case sensitive language?
Yes
What is the base index of arrays in C#
Zero
What are the two kinds of errors in C#
Compile Time, Run Time
In C#, what is a compile time error?
An error that occurs when the solution(project/code?) is being compiled.
In C#, what is a run time error?
A runtime error is a program error that occurs while the program is running.
In C#, what happens when a run time error is unhandled?
The CLR will shut down the application so it can not continue.
In a C# console app, where can I pass arguments for the debugger?
In the project properties, Debug tab, Command line arguments.
In Visual Studio, what is the autos debugging window for?
Show variables used around the current breakpoint.
What does it mean to say that C# is a typed language?
You have to have a type for every variable that you define.
In C# how do you name variables inside a method.
Starts with lower case letter. Each new word in the variable starts with an upper case letter.
In C# how do you name methods and classes?
Starts with an upper case letter.
What is in a class definition?
Starts with class keyword and name of the class. Everything inside is a class member.
What is a class State member
A class member that holds data
What is a class Behavior member
Members that do work. Methods is an example.
A field
Holds state for the class. It’s a class member. Field naming collection is lower case.
What does initializing an object do.
Reserves memory and give you a pointer to the memory?
Will C# accept an int as a float for a parameter typed as a float?
Yes
Will C# automatically accept a double as a float for a parameter typed as a float?
No.
How can you get C# to accept a double as a float?
Type an f at the end. Example 89.5f
What does the new keyword do here?: ClassName thing = new ClassName();
Instantiates an instance of the class. Creates an object. Instantiating a class invokes the constructor. The body of the constructor can contain initialization code.
Are private members visible in derived/child classes?
Only if the derived class is nested in the base class (a class defined within a class).
Where are protected members visible?
Only in derived classes.
Where are internal members visible?
Only in derived classes that are located in the same assembly as the base class.
Where are public members visible?
Public members are visible in all derived classes and can be used for any instantiation of a derived class.
Can derived classes override inherited members?
Yes, by providing an alternate implementation, but the base class member must be marked virtual. BY DEFAULT THEY ARE NOT MARKED AS VIRTUAL.
In C# what is a static class?
A static class cannot be instantiated. You can’t new it up. You access its methods by using the class name. EX. Console.WriteLine(). Console is a static class.