1. Question:Define ref, out and params modifier? 

    Answer
    In C# ref modifier is used to pass arguments by reference.
    Out: An out modifier is like a ref modifier except it need not be assigned before going into the function.
    Params: The params modifier may be specified on the last parameter of a method so that the method accepts any number of parameters of a particular type. The parameter type must be declared as an array.

    1. Report
  2. Question:Define overridden function? 

    Answer
    An override method provides a new implementation of a member that is inherited from a base class. The method that is overridden by an override declaration is known as the overridden base method. The overridden base method must have the same signature as the override method.

    1. Report
  3. Question:what is optional parameters and named arguments? 

    Answer
    Parameters are optional when a default value is specified as part of a declaration.
    Example: public List<Product> GetProductByCategory(string category, int pageIndex=0){}
    Here pageIndex is an optional parameter.
    Named arguments allow us to explicitly name an argument we are passing to a method – instead of just identifying it by argument position. 
    Example: var products= GetProductByCategory(“beverages”, pageIndex=2){} here pageIndex is a named argument.

    1. Report
  4. Question:Define Sealing function and classes. 

    Answer
    When an instance method declaration includes a sealed modifier, that method is said to be a sealed method. If an instance method declaration includes the sealed modifier, it must also include the override modifier. Use of the sealed modifier prevents a derived class from further overriding the method.

    1. Report
  5. Question:Define Boxing and Unboxing. 

    Answer
    Boxing:Boxing is the process of converting a value type to the object type or to any interface type implemented by this value type. When the CLR boxes a value type, it wraps the value inside a System.Object and stores it on the managed heap. Unboxing: Unboxing extracts the value type from the object. Boxing is implicit; unboxing is explicit. The concept of boxing and unboxing underlies the C# unified view of the type system in which a value of any type can be treated as an object.

    1. Report
  6. Question:Static vs Non static members? 

    Answer
    Static Member :The static member is callable on a class even when no instance of the class has been created. The static member is always accessed by the class name, not the instance nameNon-static Member :

    1. Report
  7. Question:Briefly describe C# access modifiers. 

    Answer
    Access modifiers are keywords used to specify the declared accessibility of a member or a type. Access modifiers are an integral part of object-oriented programming.  There are 5 different types of Access Modifiers: 
    1. Public.
    2. Internal.
    3. Private.
    4. Protected.
    5. Protected internal.

    1. Report
  8. Question:Define Interfaces. 

    Answer
    An interface is similar to a class, but it provides a specification rather than an implementation for its members. An interface contains definitions for a group of related functionalities that aclass or a struct can implement.

    1. Report
Copyright © 2024. Powered by Intellect Software Ltd