Top 5. 0 C# Interview Questions and Answers . What is C#? C# is an object oriented, type safe and managed language that is compiled by . Net framework to generate Microsoft Intermediate Language. Multiple line (/* */)Eg. This is a multiple line comment. We are in line 2. Last line of comment*//*This is a multiple line comment. We are in line 2. Last line of comment*/iii. XML Comments (///). Eg. ///. No, Multiple catch blocks can’t be executed. ![]() ![]() ![]() Once the proper catch code executed, the control is transferred to the finally block and then the code that follows the finally block gets executed. Static declared variables or methods are globally accessible without creating an instance of the class. Static member are by default not globally accessible it depends upon the type of access modified used. The compiler stores the address of the method as the entry point and uses this information to begin execution before any objects are created. And Void is a type modifier that states that the method or variable does not return any value. A class that creates an object in memory will contain the information about the methods, variables and behavior of that class. The constructor is automatically invoked whenever an object class is created. ![]()
This article lists some of the most frequently asked C# interview questions with their answers. C# Interview Questions And Answers. C# is the best language for writing Microsoft.NET applications. Hundreds of Questions And Answers To Get You Through Technical Interviews And Exams for Microsoft C#. The Art Of Selling Yourself In Any Interview. Rockin the C# Interview. Website created by Unger Technologies L.L.C. Home; Top Articles; Recent Articles; Videos; Contact us; Search: Recently Published Articles. QuestPond's interview questions and answers on ViewModel in ASP.NET MVC(Model. It constructs the values of data members while initializing the class. The elements can be of different dimensions and sizes. We can also call jagged array as Array of arrays. The process of converting an object into a stream of bytes is called Serialization. For an object to be serializable, it should implement ISerialize Interface. De- serialization is the reverse process of creating an object from a stream of bytes. The value can’t be changed afterwards. Read only is used only when we want to assign the value at run time. ![]() These abstract methods must be implemented in the inherited classes. Developers can drag and drop controls to their web forms. Attributes can be set at design time. We can easily add custom controls to Multiple Applications (If Shared Dlls), If they are private then we can copy to dll to bin directory of web application and then add reference and can use them. User Controls are very much similar to ASP include files, and are easy to create. User controls can’t be placed in the toolbox and dragged – dropped from it. They have their design and code behind. The file extension for user controls is ascx. Sealed modifier used to prevent derivation from a class. If we forcefully specify a sealed class as base class then a compile- time error occurs. When we compile, the compiler uses overload resolution to determine the specific method to be invoke. The size of the array is fixed. An arraylist is similar to an array but it doesn’t have a fixed size. Describe the accessibility modifier “protected internal”. Protected Internal variables/methods are accessible within the same assembly and also from the classes that are derived from this parent class. What are the differences between System. String and System. Text. String. Builder classes? System. String is immutable. When we modify the value of a string variable then a new memory is allocated to the new value and the previous memory allocation released. System. String. Builder was designed to have concept of a mutable string where a variety of operations can be performed without allocation separate memory location for the modified string. What’s the difference between the System. Array. Copy. To() and System. Array. Clone() ? Using Clone() method, we creates a new array object containing all the elements in the original array and using Copy. To() method, all the elements of existing array copies into another existing array. Both the methods perform a shallow copy. How can we sort the elements of the array in descending order? Using Sort() methods followed by Reverse() method. Write down the C# syntax to catch exception? To catch an exception, we use try catch blocks. Catch block can have parameter of system. Exception type. Eg. In an abstract class, we can have some concrete methods. In an interface class, all the methods are public. An abstract class may have private methods. On the other hand Finalize() is used for the same purpose but it doesn’t assure the garbage collection of an object. Using generics, we can create collection classes. To create generic collection, System. Collections. Generic namespace should be used instead of classes such as Array. List in the System. Collections namespace. Generics promotes the usage of parameterized types. It tracks the object that is currently in use, total number of objects in the pool. This reduces the overhead of creating and re- creating objects. Custom exceptions are used for them and are used defined exceptions. Delegates are required because they can be used to write much more generic type safe functions. Colon is used as inheritance operator in C#. Just place a colon and then the class name. Method overloading is creating a method with the same name within the same class having different signatures. What are the different ways a method can be overloaded? Methods can be overloaded using different data types for parameter, different order of parameters, and different number of parameters. Why can’t you specify the accessibility modifier for methods inside the interface? In an interface, we have virtual methods that do not have method definition. All the methods are there to be overridden in the derived class. That’s why they all are public. Declare the class as public and make the method sealed to prevent it from being overridden. What happens if the inherited interfaces have conflicting method names? Implement is up to you as the method is inside your own class. There might be problem when the methods from different interfaces expect different data, but as far as compiler cares you’re okay. What is the difference between a Struct and a Class? Structs are value- type variables and classes are reference types. Structs stored on the stack, causes additional overhead but faster retrieval. Structs cannot be inherited. Such types are called nullable types. Each handler is assigned to a method. It allows the instances of a class to be indexed in the same way as array. Eg. public int this. It is always advised to use “throw” because it provides more accurate error information. The attribute’s information can be retrieved at runtime using Reflection.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2017
Categories |