You are on page 1of 2

C# interview Question- Part4

1. How do I declare inout arguments in C#?


The equivalent of inout in C# is ref. , as shown in the following
example:
public void My1 (ref String str1, out String str2)
{
...
}
When calling the method, it would be called like this: String s1;
String s2;
s1 = "Hi";
My1(ref s1, out s2);
Console.WriteLine(s1);
Console.WriteLine(s2);
Notice that you need to specify ref when declaring the function and calling it
2. Can you change the value of a variable while debugging a C# application?
Yes, you can change the value of a variable while debugging a C# application.
3. What is the difference between const and static read-only?
static read only can be modified by class that containing whereas const can never be m
4. What namespaces are necessary to create a localized application?
System.Globalization, System.Resources
5. How do you inherit from a class in C#?
Place a colon and then the name of the base class.
6. Does C# support parametrized properties?
C# does not support parametrized properties. However it supports the concept of indexe
7. Does C# support C type macros?
C# doesn't support C type macros. Some of the C macros are found in .NET class but the
8. How do I convert a string to an int in C#?
Convert.ToInt32 is the keyword to be used to convert string to int.
For eg:-
class ConvStrtoInt
{
public static void Main()
{
String str = "2345";
int x = Convert.ToInt32(str);
Console.WriteLine(x);
}
}
9. What is the .NET datatype that allows the retrieval of data by a unique key?
HashTable is the datatype to be used to retrieve data by unique key.
10. What is the difference between the Debug class and Trace class?
Documentation looks the same. Use Debug class for debug builds, use Trace class for bot
11. How can I get the ASCII code for a character in C#?
Casting the char to an int will give you the ASCII value: char c = 'f'; System.Console.
12. How do I create a Delegate/MulticastDelegate?
C# requires only a single parameter for delegates: the method address. Unlike other lan
For example,
System.Threading.ThreadStart: Foo MyFoo = new Foo();
ThreadStart del = new ThreadStart(MyFoo.Baz);
13. How do you debug an ASP.NET Web application?
Attach the aspnet_wp.exe process to the DbgClr debugger.
14. What are the ways to deploy an assembly?
Some of the ways to deploy assembly are as follows:-
MSI installer
XCOPY
CAB archive
15. Difference between imperative and interrogative code.
There are imperative and interrogative functions. Imperative functions are the one whic
16. Difference between imperative and interrogative code.
There are imperative and interrogative functions. Imperative functions are the one whic
17. Explain manifest & metadata?
Manifest is metadata about assemblies. Metadata is machine-readable information about a
18. Difference between value and reference type. what are value types and reference types?
Value type - bool, byte, chat, decimal, double, enum , float, int, long, sbyte, short,
Value types are stored in the Stack
Reference type - class, delegate, interface, object, string
Reference types are stored in the Heap
19. What are the two kinds of properties.
Two types of properties in .Net: Get and Set
20. Whatâ s the advantage of using System.Text.StringBuilder over System.String?
StringBuilder is more efficient in cases where there is a large amount of string manipu

You might also like