Study

C# Programming

  •   0%
  •  0     0     0

  • What is a constraint?
    When you define a generic class, you can apply restrictions to the kinds of types that client code can use for type arguments when it instantiates you...
  • What are predicates?
    delegate function that returns true or false; convenient way of basically testing if something is true
  • What is the smallest unit of execution in .NET?
    an assembly.
  • What is a destructor?
    function (much like constructor) which is called when the object is explicitly deleted by code, or when the object passes out of scope, which can happ...
  • What are partial classes?
    class definitions can be split up across multiple physical files. To the compiler, this does not make a difference as all the fragments of the partial...
  • What is the .NET collection class that allows an element to be accessed using a unique key?
    HashTable
  • What is the C# syntax to catch any possible exception?
    a catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch{}.
  • What is the difference between a shallow copy and a deep copy?
    A shallow copy means that the contents (each array item) contains references to the same object as the elements in the original array. A deep copy wou...
  • What is static compilation?
    a compiled version of a program which has been statically linked against libraries; no dynamic linking occurs: all the bindings have been done at comp...
  • What is a namespace?
    Groups classes together so that they have a unique identifier
  • Explain how a finally block works.
    A try/catch block can be optionally followed by a finally block that will be executed whether or not the code in the try or catch blocks executes succ...
  • Can you declare an override method to be static if the original method is not static?
    No. The signature of the virtual method must remain the same. Only the keyword virtual is replaced by the keyword override.
  • What is func?
    same as a System.Predicate<T> delegate; but takes one parameter (still returns true or false).
  • What does the keyword virtual mean?
    The method or property can be overridden and most importantly, the run-time type of the object determines which method is to be invoked.
  • What is a delegate?
    a form of type-safe function pointer used by the .NET Framework.; provides level of indirection; single method interface; delegate instance is an obje...
  • What is a 'using' statement?
    defines a scope at the end of which an object will be disposed. The object you instantiate must implement the System.IDisposable interface.
  • What is the heap?
    Block of memory where objects live. Whenever a new object is created it is allowed onto the heap. Old objects are regularly deallocate from the heap t...
  • Are delegates immutable?
    yes; once you've created a delegate instance, nothing about it can be changed; makes it safe to pass around references to delegate instances and combi...
  • What is the difference between an interface and an abstract class?
    In an interface, all methods are abstract; there is no implementation at all. In an abstract class, some methods can be concrete. In an interface, no...
  • What does the Dispose() method do with the connection object?
    Closes the connection and deletes the object from memory.
  • What is lazy initialization
    tactic of delaying the creation of an object, the calculation of a value, or some other expensive process until the first time it is needed.
  • What is a primitive data type?
    basic type is a data type provided by a programming language as a basic building block; most common are: Int, Long, Float, Double, Decimal, String, Ch...
  • What are the different ways a method can be overloaded?
    A method can be overloaded with different parameter types, a different number of parameters, and different order of parameters.
  • What are attributes?
    an object that represents data you want to associate with an element in your program; the element to which you attach an attribute is referred to as t...
  • What are the four things reflection is used for?
    1) viewing metadata2) performing type discovery3) late binding to methods and properties4) creating types at runtime
  • What is JIT (just in time compiling)?
    a method to improve the runtime performance of computer programs. JIT compilers represent a hybrid approach, translation occurring continuously, as wi...
  • What is the significance of the 'where' keyword?
    public abstract class ObjectMapperBase<T> where T : new(){ internal abstract bool UpdateObject(T plainObjectOrginal, T plainObjectNew, WebMethod fwm,...
  • Can you specify the accessibility modifier for methods inside of an interface?
    No. All methods must be public.
  • Will a delegate instance prevent its target from being garbage collected?
    yes; if the delegate instance itself cant be collected; leads to memory leaks when short-lived object subscribes to an event in a long-lived object us...
  • Are private class-level variables inherited?
    Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.
  • What is encapsulation?
    process of providing access to an object only through it's messages while keeping the details PRIVATE; controls the use of a class.
  • What is reflection?
    provides objects (of type Type) that describe assemblies, modules and types. You can use reflection to dynamically create an instance of a type, bind...
  • What does the 2.0 version of C# include and when was it released?
    The 2.0 version of C# includes such new features as generics, partial classes, and iterators and was released in late 2005.
  • What are the different permutations of how to use the 'where' keyword?
    1) where T: struct2) where T : class3) where T : new()4) where T : <base class name>5) where T : <interface name>6) where T : U
  • What are the four things you need in order to use a delegate?
    1) delegate type needs to be declared2) there must be a method containing the code to execute3) delegate instance must be created4) delegate instance...
  • What happens in memory when you box and unbox a value-type?
    Boxing converts a value-type to a reference-type, thus storing the object on the heap. Unboxing converts a reference-type to a value-type, thus storin...
  • Can multiple catch blocks be executed for a single try statement?
    No. Once the proper catch block is executed, control is passed to the finally block (if there is any).
  • What is an abstract class?
    class that cannot be instantiated; a class that must be inherited and have the methods overridden; basically a blueprint for a class without ANY imple...
  • How is the DLL Hell problem solved in .NET?
    Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32) but also the version of t...
  • What are the 5 visibility levels (access modifiers)?
    1) public: available to anyone anywhere2) protected: can be accessed by the class itself and by any class derived from that class, an not any other cl...
  • What are class properties?
    class members that expose functionality of methods using the syntax of fields. They simplify the syntax of calling traditional get and set methods (a....
  • What is the significance of Application.Idle?
    it's how message processing is done on the application's UI thread; has become a convenient place to take care of application housekeeping chores asyn...
  • What is the goal of JIT?
    to reach or surpass the performance of static compilation, while maintaining the advantages of bytecode interpretation: Much of the "heavy lifting" of...
  • What is a multicast delegate?
    derives from System.Delegate; its a delegate that points to several methods. Multicast delegation is a mechanism that provides functionality to execut...
  • Does C# support multiple-inheritance?
    No. C# limits classes to single-inheritance, meaning each classes inherits from a single parent class. This is done to prevent ambiguity. Interfaces a...
  • What are the three things necessary for creating extension methods?
    1) need to be defined in a static class2) need to be defined as a static method3) need to take at least one parameter defined as follows:this (keyword...
  • What are generics?
    they are classes, structures, interfaces, and methods that have placeholders (type parameters) for one or more of the types that they store or use. th...
  • How do you convert a value-type to a reference-type?
    boxing
  • What namespaces are necessary to create a localized application?
    System.Globalization and System.Resources.
  • Can you inherit multiple interfaces?
    Yes, .NET supports multiple interface inheritance.
  • What is the stack?
    Block of memory for storing local variables and parameters. Automatically grows and shrinks as function is entered and exited.
  • What are the two advantages of dynamic compilation?
    1) Often-used libraries (for example the standard system libraries) need to be stored in only one location, not duplicated in every single binary.2) I...
  • Can you allow a class to be inherited, but prevent a method from being overridden?
    Yes. Just leave the class public and make the method sealed.
  • Whats the advantage of using System.Text.StringBuilder over System.String?
    StringBuilder is more efficient in cases where there is a large amount of string manipulation. Strings are immutable so each time a string is changed,...
  • If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?
    Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside...
  • What does the keyword 'sealed' mean?
    will prevent class from being inherited.
  • What is the difference between a struct and a class?
    Structs are value-type variables and are thus saved on the stack, additional overhead, but faster retrieval. Also structs cannot inherit.
  • When is reflection useful?
    1) When you have to access attributes in your program's metadata.2) For examining and instantiating types in an assembly3) For building new types at r...
  • What is a satellite assembly?
    When you write a multilingual or multicultural application in .NET, and want to distribute the core application separately from the localized modules,...
  • When do you absolutely have to declare a class as abstract?
    1) When the class itself is inherited from an abstract class2) When at least one of the methods in the class is abstract.
  • What are extension methods?
    Extension methods are a form of syntactic sugar providing the illusion of adding new methods to the existing class outside its definition. In practice...
  • What are lambdas?
    Lambda expressions provide a concise way to write first-class anonymous function values. ex: listOfFoo.Where(x => x.Size && > 10);lambda expressions a...
  • What is the CLR?
    Common Language Runtime: the virtual machine component of Microsoft's .NET framework and is responsible for managing the execution of .NET programs. I...
  • What is C#
    General purpose, type safe, object oriented, platform neutral programming language. Works best with the windows .Net framework and is the most up to d...
  • What is the implicit name of the parameter that gets passed into the set method/property of a class?
    The data type of the "value" parameter is defined by whatever data type the property is declared as.
  • When should you call the garbage collector in .NET?
    As a good rule, you should NOT call the garbage collector. However, you could call the garbage collector when you are done using a large object (or se...
  • What is the difference between System.String and System.Text.StringBuilder classes?
    System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be perform...
  • What does the checked keyword mean?
    used to properly check to see if an overflow exception has occurred
  • What is an interface?
    defines a set of properties, methods, and events; does not provide implementation. They are implemented by classes or other interfaces, and defined as...
  • What does the term immutable mean?
    The data value MAY NOT be changed. Note: The variable value may be changed, but the original immutable data value was discarded and a new data value w...
  • What is the .NET Framework?
    a software framework developed by Microsoft that runs primarily on Microsoft Windows. It includes a large library and provides language interoperabili...