Interview

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

CLR is .NET equivalent of Java Virtual Machine (JVM).

It is the runtime that converts a MSIL code into the


host machine language code, which is then executed appropriately. The CLR is the execution engine
for .NET Framework applications. It provides a number of services, including:
? Code management (loading and execution)
? Application memory isolation
? Verification of type safety
? Conversion of IL to native code.
? Access to metadata (enhanced type information)
? Managing memory for managed objects.
? Enforcement of code access security
? Exception handling, including cross-language exceptions
? Interoperation between managed code, COM objects, and pre-existing DLL's (unmanaged code and
data)
? Automation of object layout
? Support for developer services (profiling, debugging, and so on).

2)CTS

CTS provides a type system that is common across all languages.CTS defines how data types are
declared,used,&managed in the code during runtime.It also defines rules that ensures that the
data types of object written in various languages are able to interact with each other.

3)ADO and ado.net

In ado we don't have providers to get connection with database and also we don't have classes
like DataSet and dataadapter.
whereas in ado.net we have providers like MSDAORA.1 for oracle server and
DAMYSQL for MYSQL server to get connection with oracle and mysql server.

is it wise to say ADO.NET is a disconnected model? since we have datareader which is a


connected data model

4)strong name

Strong Name is required to register the assembly into GAC. Conatins the assembly name,
versoin etc. info.
5)Assemblies are similar to dll files. Both has the reusable pieces of code in the form of classes/
functions. Dll needs to be registered but assemblies have its own metadata. Two types of
assemblys: Shared assembly and private assembly.

Stay at Home and Learn

 Debugging your code is something you will need to do. Unless you write perfect code
every time, there's no getting away from it. In this section, we'll take a look at ways you
can track down errors using VB.NET.

Types of Error
Programming errors are generally broken down into three types: Design-time, Runtime, and
Logic errors.

A Design-time error is also known as a syntax error. These occur when the environment you're
programming in doesn't understand your code. These are easy to track down in VB.NET,
because you get a blue wiggly line pointing them out. If you try to run the programme, you'll get
a dialogue box popping up telling you that there were Build errors.

Runtime errors are a lot harder to track down. As their name suggests, these errors occur when
the programme is running. They happen when your programme tries to do something it shouldn't
be doing. An example is trying to access a file that doesn't exist. Runtime errors usually cause
your programme to crash. If and when that happens, you get the blame. After all, you're the
programmer, and you should write code to trap runtime errors. If you're trying to open a database
in a specific location, and the database has been moved, a Runtime error will occur. It's your job
to predict a thing like this, and code accordingly.

Logic errors also occur when the programme is running. They happen when your code doesn't
quite behave the way you thought it would. A classic example is creating an infinite loop of the
type "Do While x is greater than 10". If x is always going to be greater than 10, then the loop has
no way to exit, and just keeps going round and round. Logic errors tend not to crash your
programme. But they will ensure that it doesn't work properly.
To open up a text file, you need to create something called a "StreamReader". This, as its name
suggests, reads streams of text. The StreamReader is an object available to System.IO. You
create a StreamReader like this:

Dim FILE_NAME As String = "C:\test.txt"

Dim objReader As New System.IO.StreamReader(FILE_NAME)

The first line just sets up a string variable called FILE_NAME. We store the path and name of
our text file inside of the string variable:

= "C:\test.txt"

We're saying that there is a text file called test which is at the location (path) "C:\".

You set up the StreamReader to be a variable, just like a String or Integer variable. But we're
setting up this variable differently:

Dim objReader As New System.IO.StreamReader(FILE_NAME)

We've called the variable objReader. Then, after the "As" word comes "New". This means
"Create a New Object". The type of object we want to create is a StreamReader object:

System.IO.StreamReader

Sysytem is the main object. IO is an object within System. And StreamReader is an object
within IO.

StreamReader needs the name of a file to Read. This goes between a pair of round brackets:

System.IO.StreamReader(FILE_NAME)

VB will then assign all of this to the variable called objReader. So instead of assigning say 10 to
an Integer variable, you are assigning a StreamReader to a variable.

No more reading these lessons online - get the eBook here!

Read To End

But this won't do you any good. We haven't actually opened the text file yet. We've just told VB
where the text file is and what object to open it with. You do the opening like this:
TextBox1.Text = objReader.ReadToEnd

Now that objReader is an object variable, it has its own properties and methods available for use
(in the same way that the textbox has a Text property).

One of the Methods available to our new StreamReader variable is the ReadToEnd method. This
will read the whole of your text, right to the end. We're then popping this in a textbox.

Let's test all this theory out. Do the following:

 Start a new project


 Add a textbox to your new form, and just leave it on the default Name of Textbox1
 Set its MultiLine property to True
 Add a Button to your form
 Double click the button and add the following code for it:

Dim FILE_NAME As String = "C:\test.txt"

Dim objReader As New System.IO.StreamReader(FILE_NAME)

TextBox1.Text = objReader.ReadToEnd

objReader.Close()

The last line closes the StreamReader we set up. You have to close your stream objects after
you’ve used them, otherwise you’ll get errors messages.

You might also like