.Net Deck 2 Flashcards
Write out C# function that accepts two numbers - adds these numbers - returns the result of the addition:
public static int Sum(int num1, int num2) { int total; total = num1 + num2; return total; }v
Adjust the Add function from the previous answer to - accept an optional third parameter - throw an error if it is not passed at least two arguments.
public static int Sum(int num1, int num2, int? num3 = null) { int total = num1 + num2 + num3; return total; }
Describe the main differences or considerations between the JS and C#.
C# is strictly typed Object Oriented Programming Language whereas java script is loosely type client side scripting language
C# runs inside the .NET framework, so it’s good for building desktop applications, but can also be used to build web applications and servers. JavaScript runs in a browser. It can still be used to make games and stuff, but they have to run inside Firefox, Chrome, IE etc.
C# is strongly typed, meaning you have to explicitly define the types of all variables and function return types. JavaScript is weakly typed, so any variable can hold any type of value and any function can return anything. Functions can actually return other functions and variables can contain functions.
C# is object oriented, so we have classes and inheritance and the like.
C# is a compiled programming language. JavaScript (as the name implies) is a scripting language. So JavaScript can fail due to syntactic errors at run time
Does .Net support other types of Web Applications other than ASP.Net MVC?
Yes one example of other web apps supported by .Net core are single page applications.
What is the generic name of the library used in .Net that is used to communicate with Databases?
ado.net
What are the .Net objects and classes used to communicate and execute commands at the database?
SqlConnection, SqlCommand, SqlDataReader
What do you use to debug C#?
Setting a breakpoint and running program in debug mode
What is a Null Reference Exception?
A NullReferenceException happens when you try to access a reference variable that isn’t referencing any object
What is a an MVC View?
A View, in the context of a Model View Controller (MVC) architecture, is a software class that contains a template and data form and produces a response for the browser. It receives data from the Controller of the MVC and packages it and presents it to the browser for display.
What is a Model?
Model is a class which represents data object which can be used for transferring data