.Net Deck 4 Flashcards
In .Net how many classes can one class inherit from?
C# does not support multiple inheritance
You can implement multiple interfaces doe
In .Net how many interfaces can a class implement?
The C# language imposes no limit on the number of interfaces. There are two practical limits though.
The compiler will eventually run out of heap or stack space when processing large numbers of interfaces, or extremely deep hierarchies of interfaces.
Even if we fixed those problems, there would still be a second issue. Interface implementation is encoded in metadata in the InterfaceImpl table. Metadata tables typically can have no more than 2^24 members, so the total number of interfaces implemented by all types in an assembly must be less than about 16 million.
How do you declare a variable in C#?
In C# a variable id always declared with a data type.
<var>= value;</var>
string message = “Hello World”</var>
What does it mean to be a strongly typed language?
In strongly typed languages, the compiler prevents you from mixing different kinds of data together.
What are the advantages of being strongly typed?
The advantage of strongly typed languages is that the compiler can detect when an object is being sent a message to which it does not respond. This can prevent run-time errors. The other advantages of strong typing are:
earlier detection of errors speeds development
better optimized code from compiler
no run-time penalty for determining type
The disadvantages of strong typing are:
loss of some flexibility
more difficult to define collections of heterogenous objects
How can you test if an instance of an object implements a particular interface?
IBlah myTest = originalObject as IBlah
if (myTest != null)
What is a static member or property in .Net?
In C# terms, “static” means “relating to the type itself, rather than an instance of the type”. You access a static member using the type name instead of a reference or a value, e.g. Guid.NewGuid().
What does your typical error handling code look like?
try { // Some code } catch (Exception ex) { Logger.LogError(ex.ToString()); // Additional handling }
What is the Web.Config/ApplicationSettings.json? What do you use it for?
It stores passwords, account information, connection strings, and settings.
What is Authorization? At what level does it typically happen your application?
Authorization means you must be logged in to access that method. It happens in the method signature or on top of the entire controller.