0% found this document useful (0 votes)
17 views

C# - .Net - Visual Studio

Uploaded by

palesa902
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

C# - .Net - Visual Studio

Uploaded by

palesa902
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

C#/.

Net/Visual Studio
Study online at https://quizlet.com/_6to5gz
An integrated development environment created by Microsoft for
What is Visual Studio?
developing computer programs, web applications, etc.
Lines in a program beginning with the hash '#' symbol that give
What are pre-processor directives? special instructions to the compiler before the compilation process
actually starts
An open source developer platform created by Microsoft for build-
What is .NET?
ing many different types of applications
A cross platform version of the .NET framework. It has limited
What is .NET core?
capability compared to the .NET framework
A software development framework designed by Microsoft to make
programming easier. It contains a collection of class libraries (pre-
What is .NET framework? defined classes) for you to use and executes your code within the
CLR run-time environment which provides services like threading,
memory management, and exception handling.
A collection of classes [Package] which can be used in other
What is a namespace? applications. Class names declared within one namespace do not
conflict with the same class names declared in another.
First the.NET framework takes all .NET supported code (e.g., C#,
VB net, and C++) and converts it into the Microsoft Intermediate
Language (MSIL), an independent 'machine-code like' language.

MSIL is then run on the CLR, which is the virtual machine which
Can you explain the .NET framework? converts your MSIL code into 'real' machine code using the JIT
(just in time) compiler.

The reason it is called the 'just in time' compiler is because only the
MSIL needed for any particular moment is compiled into machine
code.
A CPU-independent set of instructions that can be converted to
native code by the JIT compiler.
What is Microsoft Intermediate Language (MSIL)? (Now Common
Intermediate Language CIL) .NET supported languages like C#, C++, and VBnet are all turned
into MSIL within the .NET framework and are run on the CLR
run-time environment
The virtual machine of the .NET framework which .NET programs
What is Common Language Runtime (CLR)?
are run on.
Memory management
Exception handling
What services does the CLR provide?
Garbage collection
Thread management
A compiler which is used is used as a part of the runtime execution
What is Just-In-time (JIT)?
environment. It turns CLR into machine code.
What services does the Common Language Runtime (CLR) pro- Memory Management ,Garbage Collection, Exception Handling,
vide? Common Type System
A general purpose, multi-paradigm object oriented language. It
can be used for a wide range of applications including, but not
What is C#?
limited to, windows applications, web applications, and gaming
engines
The language handles programming problems through the use
What does it mean for a programming language to be object-ori-
of classes and objects, with objects being bundles of data and
ented?
properties which act on that data
They are used to control security of a class, method, or variable
What are access specifiers in C#?
and help achieve encapsulation
The general rule of thumb is that all members are given the most
What is the default access specifier in C#? restrictive access specifier they can have by default. For example,
class fields are by default private.

1 / 18
C#/.Net/Visual Studio
Study online at https://quizlet.com/_6to5gz
By default public and abstract (no other access modifiers are
What is the default access specifier for interface members?
allowed)
What is the default access specifier for class and struct members
By default private
members?
What is the default access specifier for classes and structures? By default internal, and can only be either public or internal
What is the default access modifier for namespaces? By default public (no access modifiers allowed)
What is a solution in visual studio? A container of one or more related classes
It is contained within a solution and holds all the source code,
What is a project in visual studio? images, and data files that are compiled into an executable or
library
Value (e.g., int, float, char, byte)
What are the two types of variables in C#?
Reference (e.g., String, Object)
Value types variables directly store their value in the stack while
reference type variables store a reference address in the stack
which points to the location of where the variable's value is stored
in the heap.

What is the difference between value type and reference type? Two reference type variables can hold the same reference, and
therefore changes in one will affect the other.

Value type variables hold their own unique value, and therefore
changes in one do not affect the other (even if they hold the 'same
value'.
What are some examples of value data types? int, float, char, byte, decimal
What are some examples of reference data types? String, Object.
Methods that are associated with the class itself, not an object of
What are static methods?
the class, and therefore are called without class instantiation
What is a class? A blueprint that defines object variables and methods.
Special methods of the class which are used to assign initial
What are constructors?
values to the data members of the class.
Also known as a destructor, it is used to perform any necessary
What is a finalizer? final cleanup when a class instance is being collected by the
garbage collector
A special method inside the class used to destroy instances of that
class when they are no longer needed.
What is a destructor?
It is distinguished from the constructor by the tilde '~' symbol
The code which is developed in the .NET framework and is han-
What is managed code?
dled directly by the CLR
Code that is developed outside the .NET framework and is not
What is unmanaged code? handled by the CLR. Instead, it must be handled manually by the
programmer
When used with a base class method, it allows the method to be
What does the virtual keyword do?
overridden in a derived class
By providing the 'override' keyword in the derived class's method
How do you override a virtual method?
declaration
public override double Area()
{
Example of method overriding
// Derived implementation
}

No, it is an error to do so because the static keyword denotes


Can you use the virtual modifier on a static property or method?
something that does not change across all instances of a class,

2 / 18
C#/.Net/Visual Studio
Study online at https://quizlet.com/_6to5gz
while the virtual keyword is supposed to allow a property or
method to be changed within a derived class
[Access modifier] [Class keyword] [Identifier (i.e. class name)]
What is the syntax for class declaration?
'public class MyClass'
[access modifier] [return type] [method name] [parameters]
What is the syntax for method declaration?
public void MyMethod(int parameter1, string parameter2)
[data type] [variable name] [assignment operator] [value]
What is the syntax for variable declaration?
int i = 1;
Is C# case sensitive? Yes, this includes variable and method names
What is a field? Fields are ordinary member variables of a class
Properties are used to get and set field values (aka accessor
What is a property?
methods aka getters & setters)
Commonly known as getters and setters, they are methods used
What are accessor methods?
to access private field values
What is a method? A code block that executes a series of statements
Inheritance
Polymorphism
What are the 4 pillars of OOP?
Encapsulation
Abstraction
The ability to create a class that inherits attributes and behaviors
What is inheritance?
from an existing class
What is the benefit of inheritance? It provides for code reusability
In the derived class's declaration you provide a colon ':' and the
How is Inheritance achieved in C#?
name of the base class it is inheriting from
public class DerivedClass : BaseClass
{
Example of inheritance
//Derived class properties and methods
}
No. C# limits classes to single-inheritance, meaning each classes
inherits from a single parent class. This is done to prevent the pos-
Does C# support multiple-inheritance? Why or why not?
sible ambiguity between base class method calls (e.g. diamond
problem)
One of the four pillars of OOP which means 'having many forms'.
What is polymorphism? In particular it refers to the ability to present the same interface for
different forms
Helps promote flexibility in designs by allowing the same method
What is the benefit of polymorphism?
to have different implementations
Compile time (static)
What are the two kinds of polymorphism?
Runtime (dynamic)
It is achieved by using method overloading, i.e. defining multiple
methods with the same name but with different parameters.
What is compile time polymorphism?
It allows you to perform different tasks with the same method name
by passing different parameters
It is achieved by method overriding, i.e. using override and virtual
keywords to override a base class method by creating a derived
method with the same name and parameters to perform a different
What is runtime polymorphism? task

It allows you to perform different tasks with the same method name
by calling either the base method or derived method

3 / 18
C#/.Net/Visual Studio
Study online at https://quizlet.com/_6to5gz
It allows you to hide internal state and abstract access to it through
What is the benefit of encapsulation?
properties. It also makes code more maintainable
The process of enclosing one or more items within a 'package' and
What is encapsulation?
hiding the data in a class from other classes (data-hiding)
Through the use of access specifiers. In particular, you declare all
How is encapsulation achieved? the fields of a class private and use properties (accessor methods)
to get and set the values of these fields
The process in which only the most essential details are shown to
the user

What is abstraction? Real life example:


You can drive a car without knowing how all the parts within it work
(engine/wiring). Rather, you just need to know how to operate the
most essential parts (gas pedal, brakes, blinker, etc.)
How is abstraction achieved? Through the use of abstract classes
A derived class being able to have a different method implemen-
What is method overriding?
tation of the core class.
Having multiple methods with the same name but different para-
What is method overloading?
meter datatypes or number
The derived class. A class which inherits fields and methods from
What is a child class?
another class
What is a derived class? Same as a child class: a class which inherits another class
What is a parent class? A class which inherits
What is a base class? A class which is inherited
What is the syntax for extending a class in C#? separated by : derivedclassname:baseclassname
Following are different Value Data Types in C# programming lan-
guage :
What datatypes are there in C#? a) Signed and Unsigned Integral Types b) Floating point types
c) Decimal Type d) Character Type e) Boolean Type f) Struct g)
Enumerators
A file that is automatically generated by the compiler upon suc-
cessful compilation of every .NET application which contains
What is an assembly? Common Intermediate Language (CIL) code.

Example: .dll files


If you wanted a child/derived class to be able to override a method
from the parent/base class then firstly the parent class must
be/have an:

a) An abstract class with an abstract method

How do you override an inherited method within the derived class? or

b) Have an accessible method that has been declared 'virtual'

With the parent class defined as such the child class can override
the inherited method
with the key word 'override'
Public,
Internal,
Protected,
What are the different kinds of access specifiers?
Protected internal,
Private protected,
Private
Access is not restricted anywhere, including inside the same
What does the public access specifier mean?
assembly or another assembly that references it
4 / 18
C#/.Net/Visual Studio
Study online at https://quizlet.com/_6to5gz
What does internal access specifier mean? Access is limited to the current assembly
What does protected access specifier mean? Access is limited within the class or struct and the derived class
What does protected internal access specifier mean? Access is limited to the current assembly or within derived classes
What does the private protected access specifier mean? Access is limited only to child classes within the same assembly
Accessibility is limited only inside the classes or struct in which the
What does the private access specifier mean?
member is declared. It is the least permissive access level
Protected internal means access is limited to either derived class-
What is the difference between protected internal and private
es or within the same assembly while private protected means
protected?
access is limited to only derived classes within the same assembly
What does the sealed keyword do? A keyword that stops inheritance e.g. the class can not be inherited
A keyword that create a special type of class/method that cannot
What does the abstract keyword do?
be instantiated
A purely abstract class that only contains properties and method
What is an interface? signatures. It is up to classes to provide the implementation details
for an interface, and therefore interfaces cannot be instantiated
No because they are not designed to provide any kind of specific
implementation, but they can define properties (which obtains
Can an interface contain member fields?
member fields in a roundabout way). It is still up to the class to
provide an implementation for the properties.
An interface is defined by the keyword interface and a name
starting with a capital 'I'

Example:
What is the naming convention for interfaces?
interface IEquatable<T>
{
bool Equals(T obj);
}
A special kind of class, (marked by the abstract keyword), that
cannot be instantiated, and it is designed to be inherited by other
classes. It must contain at least one abstract method, but it can
What is an abstract class?
also contain concrete methods (methods that contain an imple-
mentation in the body). It can have constructors and destructors
as well (unlike an interface).
It consists of the method name and the type of each of its formal
What makes up a method signature?
parameters. It does NOT include the return type.
Abstract:
-Can contain both abstract methods (at least 1) and concrete
methods
-Can contain constructors / destructors
-Can contain Static methods
What are the differences between an interface and an abstract -Can be partially implemented
class?
Interface:
-Can only contain abstract methods
-Does not contain constructors / destructors
-Cannot contain static methods
-Designed to be fully implemented
Are abstract methods and properties inherently virtual? Yes
No, because static methods/classes cannot be inherited or over-
Can a static method/class be abstract?
ridden
Virtual methods have an implementation and provide derived
classes the option of overriding it
What are the differences between virtual methods and abstract
methods?
Abstract methods have no implementation and derived classes
are forced to override the method

5 / 18
C#/.Net/Visual Studio
Study online at https://quizlet.com/_6to5gz
They are faster, 'light-weight' versions of classes and are defined
by the 'struct' keyword

They are value type (stored on the stack) and do not support
What is a structure?
inheritance, but they can implement interfaces

They can contain constructors, constants, fields, and methods and


struct objects can be created without the use of the 'new' keyword
A parameter is a variable in a method definition, while an argument
is the actual data that you pass into the method's parameter's
when using that method

Example:
What is the difference between a parameter and an argument?
public void test(int number){}
-'int number' is a parameter

test(myNumber);
-'myNumber' is an argument
Used to indicate that a value is passed by reference

You can use it to pass an argument to a method by reference, or


to return a value to a caller by reference
What does the ref keyword do?
It requires that the variable being passed is initialized before being
passed

Note: The ref keyword can be used on both reference types and
value types.
void Method(ref int refArgument)
{
refArgument = refArgument + 44;
}

int number = 1;
Console.WriteLine(number);
Example of passing a value type argument by ref
Method(ref number);
Console.WriteLine(number);

// Output:
1
45
class Product
{
public Product(string name, int newID)
{
ItemName = name;
ItemID = newID;
}

private static void ChangeByReference(ref Product itemRef)


Example of passing a reference type argument by ref
{
// Change the address that is stored in the itemRef parameter.
itemRef = new Product("Stapler", 99999);
}

private static void ModifyProductsByReference()


{

Product item = new Product("Fasteners", 54321);


6 / 18
C#/.Net/Visual Studio
Study online at https://quizlet.com/_6to5gz
System.Console.WriteLine("Name: {0}, ID: {1}\n",
item.ItemName, item.ItemID);

ChangeByReference(ref item);
System.Console.WriteLine("Name: {0}, ID: {1}\n",
item.ItemName, item.ItemID);
}

// Output:
Name: Fasteners, ID: 54321
Name: Stapler, ID: 99999
(used on parameters) Causes arguments to be passed by refer-
What does the out parameter modifier do? ence, but it does not require that the variable be initialized before
it is passed
(Used on parameters) Causes arguments to be passed by refer-
What does the in parameter modifier do? ence, but it does not allow the argument to be modified within the
called method
A variable that cannot be changed once it is declared (i.e. value
set at compile time)
What is a constant?
Created with the 'const' keyword
Used to create a variable whose value cannot be edited except at
What does the readonly keyword do?
run time (within the constructor)
-Classes are reference types, structs are value types

- structs are used in small programs

-Classes can contain constructors/destructor while structs cannot

-Classes use the new keyword for creating instances while struct
can create an instance without the new keyword

-A class can inherit from another class while a struct cannot


What are the differences between a structure and a class? (though it can implement an interface)

-A class can be a base class while a struct cannot

-Members of a class can be virtual or abstract while struct's


members cannot

-Two variables in a class can reference the same object and any
operation on one object would affect the other, while each variable
in a struct contains its own copy of data and any operation of one
variable can not affect another variable
Converting value type to reference types
What is boxing
Implicit
Converting reference types to value types
What is unboxing?
explicit
When you would like to force derived classes to implement meth-
Why would you want to use an abstract class (or method)?
ods, usually unique to them
specialized classes that hold many values or objects in a specific
series.
What are collections?
e.g.
ArrayList, HashTable, SortedList, Stack, Queue

7 / 18
C#/.Net/Visual Studio
Study online at https://quizlet.com/_6to5gz
A collection that specifies the datatypes of its members and so
boxing and unboxing is not required.
What are generic collections?
e.g.
List<T>, Dictionary, SortedList, Stack, Queue
Collections of objects which don't specify the datatype of its mem-
bers.
What are non-generic collections?
e.g. ArrayList, SortedList, Stack, Queue
A generic collection of key-and-value pairs that are organized
based on the hash code of the key.
What is a dictionary?
It specifies datatypes of both its keys and values
A non-generic collection of key-and-value pairs that are organized
based on the hash code of the key. It uses the key to access the
What is a hashtable? elements in the collection.

Does not specify datatypes


Interface that, if implemented, allows for the use of foreach loops
What is IEnumerable?
and iteration over non-generic collections
Interface that, if implemented, allows for the use of foreach loops
What is IEnumerable<T>?
and iteration over generic collections
A group of objects. Examples include ArrayList, List, HashTable,
What is a collection?
and Dictionary
A block of code that is treated as an object. It can be passed as
an argument to a method and returned by method calls.
What is a lambda expression?
It uses the => (lambda declaration operator) to separate the pa-
rameter list (left side of lambda declaration) from its executable
code (right side of lambda declaration)
s => s.Age > 12 && s.Age < 20
where s is the parameter,
How do you create a lambda expression in C#?
=> is the lambda operator
and the rest is the body.
A query syntax that can be used to retrieve data from different
kinds of sources
What is Linq?
it uses SQL like keywords such as 'select' 'from' and 'where'
Methods without a name. Lambda expressions can serve as an
What are anonymous methods?
anonymous method
// C# 2.0: A delegate can be initialized with inline code, called
an "anonymous method." This method takes a string as an input
parameter.
TestDelegate testDelB = delegate(string s) { Console.Write-
Line(s); };
Examples of anonymous methods
// C# 3.0. A delegate can be initialized with a lambda expression.
The lambda also takes a string as an input parameter (x). The type
of x is inferred by the compiler.
TestDelegate testDelC = (x) => { Console.WriteLine(x); };
Used to declare variables without giving an explicit type.

What is 'var' used for? It instructs the compiler to infer the type of the variable based on
the expression from the right side of the initialization statement (at
compile time)
What is an exception? A runtime error that interrupts the normal flow of an application.

8 / 18
C#/.Net/Visual Studio
Study online at https://quizlet.com/_6to5gz
IOException
-Related to file reading and writing

IndexOutOfRangeException
-Occurs when a method refers to an array index out of the arrays
range
What are some examples of exceptions?
NullReferenceException
-Occurs whenever you try to reference a null object

DivideByZeroException
-Occurs whenever you try to divide a number by zero
A process to handle runtime errors.
What is exception handling? Why do it?
We perform it so that the normal flow of the application can be
maintained even after runtime errors.
By placing code that might throw exceptions into try blocks, han-
dling exceptions within catch blocks, and wrapping up with final-
How do you handle exceptions in C#?
ly blocks to execute cleanup code regardless if exceptions are
thrown or not.
It can be used to re-throw caught exceptions and to manually throw
What does the throw keyword do?
new exceptions by using the new keyword
Allows you to specify a conditional clause for each catch block.
What are exception filters? Using exception filters let you have more control over how you
handle specific exceptions
A statement which ensures that unmanaged objects are properly
disposed of once the using block is exited (given that the objects
implement the IDisposable interface).
What is 'using'?
The compiler implicitly converts the using block into a try finally
block.

One example of a class that goes within a using block is System.IO


What is a jagged array? An array which contain arrays
A modifier used to declare a method as asynchronous, which
What does async mean? means you can move on to other methods before the async
method is finished
An operator that is applied to a task in an asynchronous method
What does await mean? to suspend the execution of the method until the awaited task
completes
A small set of executable instructions. You can run tasks asyn-
What is a Thread?
chronously
An object that represents some work that should be done, and is
What is a Task?
a higher level concept than a thread.
Faster than using objects because it avoids boxing/unboxing

Allows you to write code which is type-safe, i.e. a List<string> is


guaranteed to be a list of strings
Why would you want to use generics?
The compiler can perform compile-time checks on generics for
type safety, e.g. restrict you from trying to put an int into a list of
strings?
Program model where the execution is broken up into pieces that
What is parallel programming? will be done at the same time by different cores, processors, or
computers
Function pointers. They are a reference type variable that holds
What are delegates?
the reference to a method.

9 / 18
C#/.Net/Visual Studio
Study online at https://quizlet.com/_6to5gz
Composing multiple delegates together into a single delegate by
What does it mean to multicast a delegate?
using the '+' operator
Allow methods to be passed as an argument.
What are the advantage of delegates?
Allow multiple methods to be called on a single event.
A delegate can refer to a method which has the same signature
and return type as that of the delegate. For example:

delegate int NumberChanger(int n);

public static int AddNum(int p) {


num += p;
return num;
}
How do you create a delegate?
public static int MultNum(int q) {
num *= q;
return num;
}

NumberChanger nc1 = new NumberChanger(AddNum);

NumberChanger nc2 = new NumberChanger(MultNum);


A function that will be called when a process is done executing a
What is a callback function? certain task. Often times callback functions are just functions that
are passed as an argument to another function.
By storing a function address inside a delegate variable and then
How are callback functions made possible in C#?
pass that delegate as a parameter to a method
You can use the Debug functionality already provided by the IDE.
When you run your application with the debugger enabled you are
How do you debug in Visual Studio?
able to see into your code as it is executing and insert breakpoints
as needed.
A breakpoint indicates where Visual Studio should suspend your
running code so you can take a closer look at the values of
What are breakpoints?
variables, the behavior of memory, or whether or not a branch of
code is getting run.
Step over notifies the debugger to NOT enter a specific func-
What does it mean to 'step over'?
tion/method. Can step over by clicking Debug > Step Over(F10)
Step into notifies the debugger to enter INTO a specific func-
What does it mean to 'step into'?
tion/method. Can step into by click Debug> Step Into(F11)
What is typecasting? converting the value of one data type to another.
Implicit Type Casting: automatic type conversion
long l = i;
What are the two kinds of typecasting?
float f = l;
Explicit: double d = 765.1;
int i = (int)d;
The process of turning an object in memory into a stream of bytes
What is serialization?
so you can do stuff like storing it or sending it over a network
What are the two types of serialization? Binary Serialization and XML Serialization
What is BinaryFormatter? A class used to serialize and deserialize objects into binary format
A class that serializes and deserializes objects into and from XML
What is XMLSerializer?
documents
How do you make a class/object serializable? Add the [Serializable] attribute right before the class declaration
Process of taking the serialized object and translating it to its
What is deserialization?
former state
10 / 18
C#/.Net/Visual Studio
Study online at https://quizlet.com/_6to5gz
A library that contains functions and code which can be used by
more than one program at a time.

What is a dynamic linked library (DLL) ? .dll's can be created in Visual Studio by building a project.

If you want to use a DLL then just add a reference for the DLL file
in your project and then add it to the namespace
A class that you can use in situations where you need to make
repeated modifications to a string without creating new string
What is StringBuilder? objects.

StringBuilder objects are in a sense dynamic and mutable strings.


A list of named integer constants, and they can be defined by using
What are enums?
the 'enum' keyword
enum Days
{
Sun,
Mon,
Tue,
Wed,
Example of enum
Thu,
Fri,
Sat
};

Sun would hold the value 0


It is best to use enumerators when you find yourself needing to use
something that has distinctly defined values that are not subject
Why would you use an enum? to change.

A great example is days in a week


It provides the ability to implement the functionality of a single
What does the partial keyword do? class into multiple files, and all these files are combined into a
single class at compile time
What is a static constructor? A constructor used to initialize static data members of a class
It is called automatically by the CLR before the first instance of the
class is created

It does not take access modifiers or have any parameters


What are some characteristics of a static constructor?
It cannot access any non-static data member of any class

A class can only have one static constructor

It cannot be inherited or overloaded


It is used to refer to the current instance of the class
What is the 'this' keyword used for?
Pass an object as a parameter to other methods
Use to access members of a base class from within a derived
class.
What is the 'base' keyword used for?
For example, to access a base class method that has been over-
ridden by a derived class method
What are the different types of generic delegates? Action, func, and predicate.
A generic delegate that does not return a value. It can be used to
What is an action?
reference method that has a void return type

11 / 18
C#/.Net/Visual Studio
Study online at https://quizlet.com/_6to5gz
public delegate void Print(int val);

static void ConsolePrint(int i)


{
Console.WriteLine(i);
}
Action example
static void Main(string[] args)
{
Print prnt = ConsolePrint;
Prnt(10);
}
A generic delegate that returns a single value. It can be used to
What is 'func'?
store references to methods which have a single return type
static int Sum(int x, int y)
{
return x + y;
}

static void Main(string[] args)


{
Example of a 'func'
Func<int,int, int> add = Sum;

int result = add(10, 10);

Console.WriteLine(result);
}
}
A generic delegate that returns a true or false value. It can be used
What is 'predicate'?
to store references to methods which return a boolean
static bool IsUpperCase(string str)
{
return str.Equals(str.ToUpper());
}

static void Main(string[] args)


Predicate example {
Predicate<string> isUpper = IsUpperCase;

bool result = isUpper("hello world!!");

Console.WriteLine(result);
}
Checking that your code is working as expected by breaking down
What is unit testing? the functionality of your program into small discrete units that you
can test individually
AAA

Arrange
- Setup the code that is required for the test and setup your
expectations
What is the generic methodology used in unit testing?
Act
- Call the method that you want to test

Assert
- Verify whether or not the expectations you set were met
XUnit
What are the two extensions in unit testing?
NUnit

12 / 18
C#/.Net/Visual Studio
Study online at https://quizlet.com/_6to5gz
What is the 'is' keyword used for? To check if a variable is of a given type
Attempts to cast a variable to another type, and if it fails it will return
What is the 'as' keyword used for?
null
Used to inform the JIT compiler that the value of the variable might
What does 'volatile' mean?
be changed by multiple threads
Const: once declared it cannot be changed(compile time). read-
What are the differences between const and read-only?
only: can only be changed by a constructor (runtime)
What is the namespace for serialization? System.Runtime.Serialization;
Assigning multiple class objects to a single delegate(Delegate
What is a multicast delegate?
allMethods = delegate1 + delegate2; )
What class do all classes in C# inherit from? System.Object
Begin by catching the more specific exceptions and then work
towards more generic exceptions.

How should you order your catch blocks? The reason for this is because once a catch block catches an
exception the rest are ignored, and handling generic exceptions
first might not give you everything you need to know to truly solve
the exception
Code that you want to be executed whether or not an exception
What kind of code would you put into a finally block? is thrown. Usually you will place 'cleanup' code that takes care of
unmanaged code here
Code that uses pointers
What are some examples of unmanaged code?
Any code that is not supported by the CLR runtime environment
In:
Used to pass readonly arguments by reference to a method

Out:
Used to pass arguments by reference to a method, but the argu-
What are the differences between in, out, and ref
ment does not need to be initialized

Ref:
Used to pass arguments by reference to a method, but the argu-
ment does need to be initialized
Yes, and this means that it has a type system that is checked at
compile time.
Is C# statically typed? If so, what does that mean?
The workaround is to use the 'dynamic' keyword
No, it supports a multiple different classes inheriting the same
Does C# support multiple inheritance?
class, however, one class cannot inherit multiple classes.
Can an interface extend another interface in C#? yes
An acronym for the first five object-oriented design principles. They
are:

1) Single Responsibility Principle


What are SOLID Design principles?
2) Open Closed Principle
3) Liskov Substitution Principle
4) Interface Segregation Principle
5) Dependency Inversion Principle
A SOLID principle that states a single class should be responsible
What is the single responsibility principle?
for only one task.
A SOLID principle that states that you should write code that
doesn't have to be changed every time the requirements change.
What is the open closed principle?
In particular, base classes should be created with only required
functionality, because doing so ensures that they will not have to
13 / 18
C#/.Net/Visual Studio
Study online at https://quizlet.com/_6to5gz
be modified in the future (closed for modification). On the other
hand, derived classes should be 'open for modification'.
A SOLID principle that states that if any part of a program is
using a Base class then the reference to that base class can be
What is the Liskov substitution principle?
replaced with a derived class without affecting the functionality of
the module
A SOLID principle that states you should make create fine-grained
What is the interface segregation principle? (specific) interfaces which do not force clients (implementation
classes) to implement methods that they do not use.
A SOLID principle that states the
What is the dependency inversion principle? details should depend on abstractions, and not the other way
around.
The Gang of Four(GoF) design patterns are 23 distinct solutions
What are Gang of Four design patterns? to general problems that software developers face during software
development
Design patterns that deal with object creation

Examples:
What are creational design patterns?
Abstract Factory
-Creates an instance of several families of classes
Singleton
-A class of which only a single instance can exist (logger)
Define relationships between classes or objects
What are structural design patterns?
Examples:
Define manners of communication between classes and objects.

Examples:
What are behavioral design patterns?
Mediator
-Defines simplified communication between classes
Observer
-A way of notifying change to a number of classes
The process used design, develop, and test high quality software
that meets customer expectations

Phases:

Planning
-Gather information about the requirements for the software you
are building and then propose a plan for moving forward

Analysis/Design
What is the software development life cycle (SDLC)? -Design the best possible structure for the software product

Building
-Begin actual development

Testing
-Test the product and see if everything is working as expected

Deployment
-Release the product to the customer/market after all required
testing is done
A software development model that entails going through all the
steps of the SDLC without any input from the end user, usually
What is waterfall development?
takes place over a long period of time

14 / 18
C#/.Net/Visual Studio
Study online at https://quizlet.com/_6to5gz
You would use this development model when you to have the
product fully operational and complete when you present it to the
end user, e.g. military aircraft
A software development methodology that delivers partial func-
tionality in rapid iterations, requiring frequent communication be-
tween the developers and the customer

SaaS (Software as a Service) products (e.g. email apps and bike


rental apps) are often handled using agile development. It's best to
get a functional app out as soon as possible, and then continually
What is agile development?
add/enhance the app as needed.

A great example of a product that can benefit from agile devel-


opment are Software As A Service(SaaS) products...such as an
email app, a bike rental app...etc...by having a minimal functional
app on the market developers can continually enhance the existing
app and add new features as needed
An implementation of Agile development

The key principle is that the customer can change their minds
What is scrum? about what they want at any point during development.

There is a strong focus on working in teams in order to deliver


products quickly
A person who facilitates the work performed within scrum devel-
What is a scrum master?
opment
What is selenium? A tool that automates browsers and user events
A type of software testing that aims to ensure that most of the
important functions of an application work.
What is smoke testing?
The result of smoke testing determines if a build is stable enough
to proceed with further testing
A service in the .NET framework which provides access to data
sources such as SQL Server

Process:
ADO.NET
1) Connection
2) Command
3) Execute
Any service that communicates data over that web
What are web services (API)
E.g. REST and SOAP
An XML-based messaging protocol for exchanging information
What is Simple Object Access Protocol (SOAP)?
among computers
Actual document that describes the details of the SOAP request.
This is written in XML format.
What is a SOAP envelope?
Has a header and a body similar to an HTML webpage.

Connect with
An architectural style for communication between a client and a
server which allows each one to be done independently without
knowing about the other.
What is representational state transfer (REST)?
This means you can change code on the client side without
affecting the server side, and vice versa.
What are the differences between SOAP and REST
15 / 18
C#/.Net/Visual Studio
Study online at https://quizlet.com/_6to5gz
SOAP requires XML formatting while REST supports multiple data
formats such as HTML, JSON, XML, and plain text
How many interfaces can a class implement? A class can implement any number of interfaces
The 'endpoint'...

URI stands for Uniform Resource Identifier


by creating a new instance of the URI class you can point it to a
resource(typically a url) which can then be used when making a
What is a Uri?
webrequest(side note uses 'System' namespace)

Uri siteUri = new Uri("http://www.contoso.com/");

WebRequest wr = WebRequest.Create(siteUri);
What is WebRequest? A class in the System.Net namespace used to make a SOAP calls
What is Web Services Description Language (WSDL)? WSDL documents describe a web service and is written in XML.
The volatile keyword informs the compiler that the designated
What does the volatile keyword mean? variable can have its variable changed by another thread during
run time
The waterfall methodology ensures that the software is completely
developed before being deployed.
Distinguish the difference between waterfall and agile methodol-
In the agile framework parts and components of a given product
ogy
are completed during sprints and are deployed. This allows im-
mediate feedback from end users and any bugs/defects can be
addressed in a following sprint
Use the System.Data.SqlClient namespace

Specify the database you're connecting to in the sqlconnection


string
How do you create a database connection?

Create the query command you want to execute

Execute that command and get the returned query


float,
double,
What are the different value types that can hold decimal values? Decimal,

Decimal has the greatest precision


A constructor of a class that has been declared as private.
What is a private constructor?
It prohibits the ability of creating an instance of said class for any
other code outside of the class itself
What does LINQ stand for? Language Integrated Query
A structured query syntax in C# (kind of like SQL) that is used to
What is LINQ?
retrieve data from things like databases and collections
Developers don't have to learn a new query language for each
type of data source they want to query from.

It reduces the amount of code to be written as compared to


What are the advantages of LINQ? traditional approaches.

The code is easy to read and understand

You can retrieve data in different shapes (i.e. data shaping).

16 / 18
C#/.Net/Visual Studio
Study online at https://quizlet.com/_6to5gz
What is the keyword 'using' doing? Implicitly creates a 'try/finally' block for handling unmanaged code
The step out (shift + f11) feature in debugger mode allows you to
'step out' of the function that you may have 'stepped into'
What is 'step out'
This command executes the rest of the current function and breaks
when the function return is completed.
You can use the Visual Studio provided unit tester by declaring
the namespace, specifying [TestClass] & [TestMethod] attributes
How can you unit test in visual studio? when testing classes and methods respectively

using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace BankTests
{
[TestClass]
public class BankAccountTests
Example unit test {
[TestMethod]
public void TestMethod1(){}
}
}
If you have any I/O-bound needs (such as requesting data from
a network or accessing a database), you'll want to utilize asyn-
When/why would you utilize asynchronous programming? chronous programming. You could also have CPU-bound code,
such as performing an expensive calculation, which is also a good
scenario for writing async code.
using System.Threading;
using Systme.Threading. Tasks;

class ThreadTest
{
static void Main()
{
Thread t = new Thread(WriteY);
// Kick off a new thread
t.Start();
// running WriteY()
// Simultaneously, do something on the main thread.
for (int i = 0; i < 10000000; i++)
{
Multi-Threading code snippet Console.Write("x");
Console.ReadLine();
}
}

static void WriteY()


{
for (int i = 0; i < 10000000; i++)
{
Console.Write("y");
Thread.Sleep(1000); // let the thread `sleep` for one seconds
before running.
}
}
}
A data structure that contains a sequence of elements of different
What is a tuple?
data types.
A data type that escapes type checking at compile time, and
What is a 'dynamic' type?
instead resolves it at runtime

What is the difference between var and dynamic?

17 / 18
C#/.Net/Visual Studio
Study online at https://quizlet.com/_6to5gz
var designates the type at compile time whereas dynamic evalu-
ates the type at run time
Shorthand notation for if/else statements

What is a ternary operator? The first argument takes a comparison argument, the second is
the result upon a true comparison, and the third is the result upon
a false comparison
What are nullable types? They allow you to assign null to a value type variable.
Nullable type example Nullable<int> i = null;
What is HttpClient? A class that can be used to make REST calls
If you are performing an iteration on a collection or array, it allows
What does the 'yield' contextual keyword do? you to maintain the position/value of the iterator in which yield is
used
POST
GET
PUT
DELETE
What are the HTTP methods used for CRUD operations?
Note: CRUD operations:
Create(POST)
Read(GET)
Update(PUT)
Destroy(DELETE)
Simple Object Access Protocol.

A protocol where everything is sent in xml format with a head-


What is SOAP?
er/body/footer, all placed in what is called the 'envelope'. Can work
with any application layer protocol, such as HTTP, TCP, and UDP.
It returns data to the receiver in XML format.
ADO.NET is a data access technology from the Microsoft .NET
What is ADO.net? Framework that provides communication between relational and
non-relational systems through a common set of components.[1]
What is down casting?
What is upcasting?
A component of the CLR which standardizes data types across all
What is the common type system?
.NET supported languages
What are the two components of MSIL? .dll files and .exe files
What is a partial class?
Can you use partial methods? Yes
A class that can't be instantiated.
What is a static class? Created using the "static" keyword.
Can contain static members only
The sole purpose of the class is to provide blueprints of its inher-
Why use a static class?
ited classes.
Also known as a Dynamic Link Library (DLL) or 'assembly'
What is a class library?
It is a collection of pre-written class which can be used in any
program by importing/referencing the file

18 / 18

You might also like