C Sharp

1. An Overview of C# 2. OOP 3. C# Environment 4. IDE 5. Basic Requirement 6. Comments 7. My first program 8. Line Break 9. Escape Sequence 10. Identifiers 11. Variables 12. Datatypes 13. Range of datatypes in C# 14. Declare Variables 15. Reserved Key Words 16. Console.Write() 17. Chained & Embedded state 18. Prog.to print sum of 2 nos 19. Console.ReadLine() 20. Prg.to print sum & average 21. Area & Perimeter of Rectangle 22. Area Circumference of Circle 23. Prg.for Simple Calculator 24. Operatos in C# 25. Ex. Of Operators 26. Prg. to Swap two numbers 27. Hierarchy of Operators 28. if( ) statement 29. Prg.to check +ve,-ve or zero 30. if..else statement 31. Prg.to check Odd or Even 32. Prg.to print larger of 2 nos 33. Prg.to print largest of 3 nos 34. Prg.to check divisibility 35. Prg.to check print range 36. for. . . loop statement 37. prg.to print series of nos 38. Prg.to check divisibility 39. prg.to print sum of series 40. Prg.to print Pyramid 41. prg.for Factorial 42. prg.to fill screen 43. prg.for largest/smallest no 44. prg.to print reverse no 45. prg.to add each digit 46. prg.for sum of Factorial 47. prg.for fibonacci series 48. prg.to check Prime nos 49. prg. Prime no from 1 to 100 50. prg.Specified Prime nos 51. while( ) statement 52. do. . While statement 53. goto statement 54. break & continue statement 55. switch case statement 56. Array in C# 57. print reverse order using array 58. Ascending/Descending order 59. prg.to search no in Array 60. Multidimensional arrays 61. String in C# 62. String with spaces 63. prg.to print string in reverse 64. prg.to count A,E,I,O,U vowel 65. User Define Methods 66. Methods program example 67. General Purpose Programs 68. Loan & EMI calculation prg. 69. Table print prg. 70. Leap year program 71. lower to UPPER case prg. 72. Age Distribution prg. 73. Bank note calculation prg. 74. Simple Interest prg. 75. Compound Interest prg. 76. Simple Depreciation prg. 77. Reducing bal.Depreciation prg. 78. Marksheet prg. 79. Income Tax prg. 80. Time calculator prg. 81. Distance converter prg. 82. Volume Air Calculation prg. 83. Time to fill Water Tank prg. 84. Salary Calculation prg. 85. Total Sale Calculation prg. 86. Male/Female pecentage prg. 87. Library Rent prg. 88. Office Expance prg. 89. Total Salary Calculation prg. 90. Profit or Loss prg. 91. Total Profit/Loss prg. 92. Virtual Function . 93. C# Interview Part1 94. C# Interview Part2 95. C# Interview Part3 96. C# Interview Part4 97. C# Interview Part5 98. C# Interview Part6 99. C# Interview Part7 100. C# Interview Part8 101. C# Interview Part9 102. C# Interview Part10 103. C# Interview Part11 104. C# Interview Part12 105. C# Interview Part13 106. C# Interview Part14 107. C# Interview Part15
Pr.Pg Next Pg

C# Interview Questions and Answers Part 3


21.Can you have two files with the same file name in GAC?

  • Yes, remember that GAC is a very special folder, and while normally you would not be able to place two files with the same name into a Windows folder, GAC differentiates by version number as well, so itís possible for MyApp.dll and MyApp.dll to co-exist in GAC if the first one is version and the second one is


22. What are value types and reference types?

  • Value types are stored in the Stack whereas reference types stored on heap.

  • Value types:

  • int, enum , byte, decimal, double, float, long

  • Reference Types:

  • string , class, interface, object.


23. What are Custom Control and User Control?

  • Custom Controls are controls generated as compiled code (Dlls), those are easier to use and can be added to toolbox. 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.


24. Is there an equivalent of exit() for quitting a C# .NET application?

  • Yes, you can use System.Environment.Exit(int exitCode) to exit the application or Application.Exit() if it's a Windows Forms app.


25.Can you prevent your class from being inherited and becoming a base class for some other classes?

  • Yes, that is what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName. It is the same concept as final class in Java.



26. What is the difference between method overriding and method overloading?

  • In method overriding, we change the method definition in the derived class that changes the method behavior. Method overloading is creating a method with the same name within the same class having different signatures.


27.If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor?

  • Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.



28. What is the difference between Array and LinkedList?

  • Array is a simple sequence of numbers which are not concerned about each others positions. they are independent of each others positions. adding,removing or modifying any array element is very easy.

  • Compared to arrays ,linked list is a comlicated sequence of numbers.


29. What is the difference between private and public keyword?

  • Private : The private keyword is the default access level and most restrictive among all other access levels. It gives least permission to a type or type member. A private member is accessible only within the body of the class in which it is declared.

  • Public : The public keyword is most liberal among all access levels, with no restrictions to access what so ever. A public member is accessible not only from within, but also from outside, and gives free access to any member declared within the body or outside the body.


Pr.Pg border                                              Next Pg