C Sharp Interview Questions
C# and Dot Net Interview Questions II
What is XML Schema?
Document Type Declaration(DTD)
<!DOCTYPE root-element [ doctype-declaration… ]>
determines the name of the root element and contains the document type declarations
Elements
Elements are the main building blocks of both XML and HTML documents.
Examples of HTML elements are “body” and “table”. Examples of XML elements could be “note” and “message”. Elements can contain text, other elements, or be empty. Examples of empty HTML elements are “hr”, “br” and “img”.
Examples:
<body>body text in between</body>
<message>some message in between</message>
———–
Attributes
Attributes provide extra information about elements.
C# and Dot Net Interview Questions III
How to find exceptions in database
If program successfully complie . but program is not run or execute.then give an exception.
How can objects be late bound in .NET?
Instead of using new keyword we can use create object like in this example we are creating object to write in excel sheet through our programexampleImports Excel = Microsoft.Office.Interop.ExcelPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim objApp As Object Dim objBook As Object Dim objBooks As Object Dim objSheets As Object Dim objSheet As Object Dim range As Object ‘ Instantiate Excel and start a new workbook. objApp = CreateObject(”Excel.Application”) objBooks = objApp.Workbooks objBook = objBooks.Add objSheets = objBook.Worksheets objSheet = objSheets.Item(1) range = objSheet.Range(”A1″) ‘Set the range value. range.Value = “Hello, World!” ‘Return control of Excel to the user. objApp.Visible = True objApp.UserControl = TrueEnd Sub
C# Interview Questions III
What is the difference between shadow and override?
Overriding is used to redefines only the methods.but shadowing redefines the entire element.
You have an event handler called MyEvent and you want to link the click event of control, MyButton, to use MyEvent, what is the code that will like them together?
control.Click += new EventHandler(MyEvent)
Which debugging window allows you to see the methods called in the order they were called?
The call stack.
Which debugging window allows you to see all the name and values of all the variables in scope?
C# Interview Questions
- Does C# support multiple-inheritance?
No. - Who is a protected class-level variable available to?
It is available to any sub-class (a class inheriting this class). - Are private class-level variables inherited?
Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited. - Describe the accessibility modifier “protected internal”.
It is available to classes that are within the same assembly and derived from the specified base class. - What’s the top .NET class that everything is derived from?
System.Object.
Class Questions
- What is the syntax to inherit from a class in C#?
Place a colon and then the name of the base class.
Example: class MyNewClass : MyBaseClass - Can you prevent your class from being inherited by another class?
Yes. The keyword “sealed” will prevent the class from being inherited. - Can you allow a class to be inherited, but prevent the method from being over-ridden?
Yes. Just leave the class public and make the method sealed. - What’s an abstract class?
A class that cannot be instantiated. An abstract class is a class that must be inherited and have the methods overridden. An abstract class is essentially a blueprint for a class without any implementation.