C# interview Question And Answer 2020 - part 3

Category > CSHARP || Published on : Wednesday, November 11, 2020 || Views: 773 || C# interview Question And Answer 2020 - part 3


1. Explain the three services model commonly know as a three-tier application.
The three service model in three tier application are
Data
Business
Presentation

2. what are the rules to be followed while naming variable in C#?
The following are the rules to be followed
It should be unique
It can have any number of character
Shouldn't use keyword as names
It should start with letter or underscore.

3. What are the different types of Data?
C# supports two types of data:-
Value type: - Value type directly contains the data. Once the variable declared the system allocates memory to store value
Reference type: - They don't contain variable rather the reference to the variable.

4. Explain about comment entry?
Comments is also a part of the program that explains about the code. Compilers ignore the comments. comments are enclosed within '/* and */.

5. Explain about protected internal access specifier?
internal access specifier will hide the member function and variables to be accessed by other function and objects, other then the child class. It plays an important role during implementing inheritance.

6. How do you specify a custom attribute for the entire assembly (rather than for a class)?
Global attribute require to appear on top level and before the namespace specification.
For eg:-
using System;
[assembly : MyAttributeClass] class X {}

7. How do you mark a method obsolete?
[Obsolete] public int x1() {...}
Obsolete is the keyword used in front of the method to make it obsolete.

8. What do you know about .NET assemblies?
Assemblies are the smallest units of versioning and deployment in the .NET application. Assemblies are also the building blocks for programs such as Web services, Windows services, serviced components, and .NET remoting applications.

9. What’s the difference between private and shared assembly?
The assembly used inside the application are called as private assembly, they do not require any strong name to be identified.
shared assembly as the name indicates can be used by multiple applications and it is very much essential that it has a strong name.

10. What’s a strong name?
A strong name require to have the following fields:-
assembly,
version number,
culture identity,
public key token.

11. 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 1.0.0.0 and the second one is 1.1.0.0.

12. How can you create a strong name for a .NET assembly?
Strong Name tool (sn.exe) which can be used to create strong name.

13. What is delay signing?
It allows to place a shared assembly by just placing a public key in the assembly. It is more secure and helps the developers to work with strong name and shared assemblies.

14. Is there an equivalent of exit() for quitting a C# .NET application?
System.Environment.Exit is an equivalent of exit() that enables to quit from the application.

15. How do I make a DLL in C#?
target:library compiler option inorder to make a DLL in C#.

16. Is there regular expression (regex) support available to C# developers?
Yes, regular expression are supported by .NET class. System.Text.RegularExpressions namespace provide the expression for regular expression.

17. What connections does Microsoft SQL Server support?
Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords)

18. What is trace and debug in C#?
.NET allows very useful class that help in monitoring the working of the program. Trace and Debug can be very powerful development tools that can help kill hard to find bugs by making them glaringly obvious.

19. What optimizations does the C# compiler perform when you use the optimize+ compiler option?
optimize branches over branches
unreachable code
getting rid of unused locals.

20. How do I create a multi language, multi file assembly?
Unfortunately, this is currently not supported in the IDE. To do this from the command line, you must compile your projects into netmodules (/target:module on the C# compiler), and then use the command line tool al.exe (alink) to link these netmodules together.

Web Development Interview Questions
Database Interview Questions
Mobile Development Interview Questions
Others Interview Questions