Question:-Can it is possible that pointer are also in C#?
Answer:Can you believe C# supports pointers but in a limited extent. We all know pointer is variable that only holds the memory address of another type. But pointer are little different in C# these declared to hold the memory address of value types and arrays also pointer types are not tracked by the default garbage collection mechanism. Pointers are not allowed to point to a reference type or even to a structure type which contains a reference type. Pointers only point to unmanaged types which includes all basic data types, enum types, other pointer types and structs which contain only unmanaged types.
Question:-What is Generic class how it helps programmer ?
Answer:Generic is new feature included in .NET it is essential in C# .Because today the projects are more complicated as past so programmer badly need touse better reuse and customize their existing component-based software. So get this high level of code reuse in other languages, programmers have a option that option is Generics .By Using Generics, we can create class templates that support any type.
Question:-What is Partial class ?
Answer:Partial class can also be split into two or more classes. We can also say that a class be physically separated into other parts of the class but within the same namespace and also one more important thing the parts must use the partial keyword.And other classes should also have the same access modifier.When compile is done, all the partial classes will be treated as a single class. Let us list some advantages of having partial classes.
• Allows a clean separation of business logic layer and the user interface.
• The UI code can be hidden from the developer.
• Makes the debugging easier..
Question: what are the Hiding method in c# can it is possible to hide method without using Virtual Function?
Answer: It is possible to hide the base class method with the derived class without using Virtual in base class and Override keyword in subclass.there are some condition where we have to redefine any method in derived class same name in base class now question arise how can we hide the method anwer is simple and logical we use the modifier NEW which tell the compiler that derived class method "hides the base class method. There are some example: Class baseclass
{
Public void display()
{
console.writeline("base method");
}
}
class derived : baseclass
{
public new void display()
{
console.writeline("dervied mthod");
}
}
class test
{
public static void main()
{
derived d=new derivedclass();
d.display();
}
}
Question:-explain some of method of System.Array class ?
Answer:-
Clear():-Set ranges of value to empty.
CopyTo():-Copies element source to desinations.
GetLength()-:Display number of element in given array.
GetValue():-Value of given index in array.
Length():-To get length of array.
SetValue():-Sets the value of given index in the array.
Reverse() :-Reverse the element of Array.
Sort():-Sort the element in array.
Question: what do u mean by Array in C# ?
Answer:Array is a group of same type of datatype variable that shared a common name .The ability to use a single name to represent a collections of item is an array.There are manily three types of array.
*One-Dimensinal Array
*Two-Dimensinal Array
*Multi-Dimensinal Array
There are three steps include to create a Array
(1) Declare an array
(2)Creating memory location
(3)Putting values into the memory location
Declare the Array:-int[] counter;(declare int array)
Creating of Array:-arrayname=new type[size];
putting values in array:-number=new int[5];
number[0]=35;
Question: What is difference between the System.Array.CopyTo() & System.Array.Clone()?
Answer:The Clone() method returns a new array object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a shallow copy. A shallow copy means the contents (each element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identacle object.
Question: Is there an equivalent of exit() for quitting a C# .NET application ?
Answer:Yes, you can use System.Environment.Exit(int exitCode) to exit the application or Application.Exit() if it’s a Windows Forms app.
Question: Is there a way to force garbage collection ? Answer:Yes. Set all references to null and then call System.GC.Collect(). If you need to have some objects destructed, and System.GC.Collect() doesn’t seem to be doing it for you, you can force finalizers to be run by setting all the references to the object to null and then calling System.GC.RunFinalizers().
Question: Is there regular expression (regex) support available to C# developers ? Answer:Yes, The .NET class libraries provide support for regular expressions. Look at the System.Text.RegularExpressions namespace.
Question: What is the difference between a struct and a class in C# ? Answer:From language spec: The list of similarities between classes and structs is as follows. Longstructs can implement interfaces and can have the same kinds of members as classes. Structs differ from classes in several important ways; however, structs are value types rather than reference types, and inheritance is not supported for structs. Struct values are stored on the stack or in-line. Careful programmers can sometimes enhance performance through judicious use of structs. For example, the use of a struct rather than a class for a Point can make a large difference in the number of memory allocations performed at runtime. The program below creates and initializes an array of 100 points. With Point implemented as a class, 101 separate objects are instantiated-one for the array and one each for the 100 elements.
Question: Why do I get a syntax error when trying to declare a variable called checked ?
Answer:The word checked is a keyword in C#.
Question: Are private class-level variables inherited ?
Answer: Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.
Question: What is the difference between the C#.NET and VB.NET ?
Answer: VB.NET - It didn't have the XML Documentation.
- It didn't have the Operator Overloading.
- It didn't have the Pointer Type variables.
C#.NET - It has XML Documentation, Operator Overloading and supports Pointer Variables using unsafe keyword.
Question: Is it possible to inline assembly or IL in C# code ?
Answer:No.
Question: What is the syntax for calling an overloaded constructor within a constructor (this() and constructorname() does not compile) ?
Answer:The syntax for calling another constructor is as follows: class B { B(int i) { } } class C : B { C() : base(5) // call base constructor B(5) { } C(int i) : this() // call C() { } public static void Main() {} }.
Question: What optimizations does the C# compiler perform when you use the /optimize+ compiler option ?
Answer: The following is a response from a developer on the C# compiler team: We get rid of unused locals (i.e., locals that are never read, even if assigned). We get rid of unreachable code. We get rid of try-catch with an empty try. We get rid of try-finally with an empty try. We get rid of try-finally with an empty finally. We optimize branches over branches: gotoif A, lab1 goto lab2: lab1: turns into: gotoif !A, lab2 lab1: We optimize branches to ret, branches to next instruction, and branches to branches.