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 .
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:-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 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: 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.
Subscribe to:
Post Comments (Atom)



No comments:
Post a Comment