C# Fundamentals Flashcards
What is the CLR?
Common Language Runtime - works in background
- Manages memory
- OS and hard independence
- Language independence; many langs
What is FCL?
Framework Class Library
- library of functionality to build apps
- large and varied
- typically focus on specific areas (ASP.NET)
What languages fed C#?
Java, C++ and JavaScript
What is csc?
Visual C# Compiler - csc.exe
csc file.cs
What does compiler do?
- Transforms C# into MSIL (MS Intermediate Language)
What are “Members”?
Basically everything within the curly braces of a Class. Everything contained within that Class.
What do Class Members define?
- State (a Field)
- Behavior - members that do work (Methods)
What does adding an “f” next to a number do?
Tells the program the number should be treated as a FLOAT
What is a Constructor?
- Special methods used to initialize objects
- All classes have an implicit constructor
- You can explicitly define a custom constructor (or multiple)
What is snippet for adding a Constructor?
- “ctor” then tab tab
What are reference types?
- Classes are reference types
- Variable holds pointer value, pointer to memory
- Multiple variables can point to same object; same point in memory
What are Access Modifiers?
- public, private, etc
- public - publically available
- default is private
What is Encapsulation?
- Hiding or not exposing some of the details of code
- Only exposing members you want to expose
What is static?
- Use static members of class without creating an instance
What is assembly?
- Compiled code in form of exe or DLL
- instructions for code to run on the CLR
What is Unit Testing?
- VS has Unit Test Project
- Use Code to test Code
What is the default access modifier for a new Class?
- the default is Internal
- this means the class can only be accessed within same project
Which attributes are used for basic C# unit testing?
- [TestClass]
- [TestMethod]
- use Asserts
What is a value type?
- data is actually stored in memory location
- no pointers, no references
- value types fast, small, less resources than reference types
- int, double, float (primitives)
What is a struct?
- create value types
- looks like Class definition
- abstractions that represent single value
- generally contain small amount of data
What is an enumeration?
- creates value type
- assign numbers to labels
What is the shortcut key to view Class/object details?
- F12
How are method parameters passed?
- parameters pass by value by default
- Ref types pass a copy of the pointer
- Value types pass a copy of the value
- use “ref” or “out” keywords to pass a reference instead of value
What is Immutability?
- the value of something cannot change
- primitive types values cannot be changed
- DateTime, string
- example, DateTime … AddDays… must assign back to variable, can’t just run date.AddDays(1) … must assign date = date.AddDays(1);
- string is not a value type but behaves like one