What is hiding in CSharp ?


Hiding is also called as Shadowing. This is the concept of Overriding the methods. It is a concept used in the Object Oriented Programming.

E.g.
public class ClassA {
public virtual void MethodA() {
Trace.WriteLine("ClassA Method");
}
}

Public class ClassB : ClassA {
public new void MethodA() {
Trace.WriteLine("SubClass ClassB Method");
}
}

public class TopLevel {
static void Main(string[] args) {
TextWriter tw = Console.Out;
Trace.Listeners.Add(new TextWriterTraceListener(tw));

ClassA obj = new ClassB();
obj.MethodA(); // Outputs “Class A Method"

ClassB obj1 = new ClassB();
obj.MethodA(); // Outputs “SubClass ClassB Method”
}
}

What is the difference between an XML "Fragment" and an XML "Document."
An XML fragment is an XML document with no single top-level root element. To put it simple it is a part (fragment) of a well-formed xml document. (node) Where as a well-formed xml document must have only one root element.

What does it meant to say “the canonical” form of XML?

"The purpose of Canonical XML is to define a standard format for an XML document. Canonical XML is a very strict XML syntax, which lets documents in canonical XML be compared directly.
Using this strict syntax makes it easier to see whether two XML documents are the same. For example, a section of text in one document might read Black & White, whereas the same section of text might read Black & White in another document, and even in another. If you compare those three documents byte by byte, they'll be different. But if you write them all in canonical XML, which specifies every aspect of the syntax you can use, these three documents would all have the same version of this text (which would be Black & White) and could be compared without problem.
This Comparison is especially critical when xml documents are digitally signed. The digital signal may be interpreted in different way and the document may be rejected.



Why is the XML InfoSet specification different from the Xml DOM? What does the InfoSet attempt to solve?

"The XML Information Set (Infoset) defines a data model for XML. The Infoset describes the abstract representation of an XML Document. Infoset is the generalized representation of the XML Document, which is primarily meant to act as a set of definitions used by XML technologies to formally describe what parts of an XML document they operate upon.
The Document Object Model (DOM) is one technology for representing an XML Document in memory and to programmatically read, modify and manipulate a xml document.
Infoset helps defining generalized standards on how to use XML that is not dependent or tied to a particular XML specification or API. The Infoset tells us what part of XML Document should be considered as significant information.

Contrast DTDs versus XSDs. What are their similarities and differences? Which is preferred and why?

Document Type Definition (DTD) describes a model or set of rules for an XML document. XML Schema Definition (XSD) also describes the structure of an XML document but XSDs are much more powerful.
The disadvantage with the Document Type Definition is it doesn’t support data types beyond the basic 10 primitive types. It cannot properly define the type of data contained by the tag.
An Xml Schema provides an Object Oriented approach to defining the format of an xml document. The Xml schema support most basic programming types like integer, byte, string, float etc., We can also define complex types of our own which can be used to define a xml document.
Xml Schemas are always preferred over DTDs as a document can be more precisely defined using the XML Schemas because of its rich support for data representation.

Speaking of Boolean data types, what's different between C# and C/C++?
There's no conversion between 0 and false, as well as any other number and true, like in C/C++.

How do you convert a string into an integer in .NET?

Int32.Parse(string)

Can you declare a C++ type destructor in C# like ~MyClass()?

Yes, but what's the point, since it will call Finalize(), and Finalize() has no guarantees when the memory will be cleaned up, plus, it introduces additional load on the garbage collector.

What's different about namespace declaration when comparing that to package declaration in Java?

No semicolon.

What's the difference between const and readonly?

The readonly keyword is different from the const keyword. A const field can only be initialized at the declaration of the field. A readonly field can be initialized either at the declaration or in a constructor. Therefore, readonly fields can have different values depending on the constructor used. Also, while a const field is a compile-time constant, the readonly field can be used for runtime constants as in the following example:
public static readonly uint l1 = (uint) DateTime.Now.Ticks;

What does \a character do?
On most systems, produces a rather annoying beep.

Can you create enumerated data types in C#?
Yes.

What's different about switch statements in C#?

No fall-throughs allowed.

What happens when you encounter a continue statement inside the for loop?

The code for the rest of the loop is ignored, the control is transferred back to the beginning of the loop.

How can you sort the elements of the array in descending order?

By calling Sort() and then Reverse() methods.

Will finally block get executed if the exception had not occurred?

Yes.

What's the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception?

A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.

Can multiple catch blocks be executed?


No, once the proper catch code fires off,
the control is transferred to the finally block (if there are any), and then whatever follows the finally block.

Why is it a bad idea to throw your own exceptions?

Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project.