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 2

 

11.How do you directly call a native function exported from a DLL?

  • Here’s a quick example of the DllImport attribute in action:

 

using System.Runtime.InteropServices; \

class C

{

[DllImport(\"user32.dll\")]

public static extern int MessageBoxA(int h, string m, string c, int type);

public static int Main()

{

return MessageBoxA(0, \"Hello World!\", \"Caption\", 0);

}

}

 

  • This example shows the minimum requirements for declaring a C# method that is implemented in a native DLL. The method C.MessageBoxA() is declared with the static and external modifiers, and has the DllImport attribute, which tells the compiler that the implementation comes from the user32.dll, using the default name of MessageBoxA.

 

12. What are the differences between System.String and System.Text.StringBuilder 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.StringBuilder 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.

 

 

13. What’s the difference between the System.Array.CopyTo() and System.Array.Clone() ?

  • Using Clone() method, we creates a new array object containing all the elements in the original array and using CopyTo() method, all the elements of existing array copies into another existing array. Both the methods perform a shallow copy.

 

 

14.What’s the difference between private and shared assembly?

  • Private assembly is used inside an application only and does not have to be identified by a strong name.

  • Shared assembly can be used by multiple applications and has to have a strong name.

 

15. What is the difference between break and continue statement?

  • The break statement is used to terminate the current enclosing loop or conditional statements in which it appears. We have already used the break statement to come out of switch statements.

  • The continue statement is used to alter the sequence of execution. Instead of coming out of the loop like the break statement did, the continue statement stops the current iteration and simply returns control back to the top of the loop.

 

16. What does a break statement do in switch statements?

  • The break statement terminates the loop in which it exists. It also changes the flow of the execution of a program.

  • In switch statements, the break statement is used at the end of a case statement. The break statement is mandatory in C# and it avoids the fall through of one case statement to another.

 

17.How can you debug failed assembly binds?

  • Use the Assembly Binding Log Viewer (fuslogvw.exe) to find out the paths searched.

 

18.Where are shared assemblies stored?

  • Global assembly cache.

 

19.How can you create a strong name for a .NET assembly?

  • With the help of Strong Name tool (sn.exe).

 

20.Where’s global assembly cache located on the system?

  • Usually C:\winnt\assembly or C:\windows\assembly.


Pr.Pg border                                              Next Pg