Sie sind auf Seite 1von 3

(B)What is a CTS?

In order that two language communicate smoothly CLR


has CTS (Common Type System).Example in VB you have “Integer” and in
C++ you have “long” these datatypes are not compatible so the interfacing
between them is very complicated. In order that two different languages can
communicate
Microsoft introduced Common Type System. So “Integer” datatype in VB6
and “int” datatype in C++ will convert it to System.int32 which is datatype of
CTS.CLS which is covered in the coming question is subset of CTS.

Assembly is unit of deployment like EXE or a DLL.

(A) What are different types of Assembly? There are two types of
assembly Private and Public assembly.A private assembly is
normally used by a single application, and is stored in the
application's directory, or a sub-directory beneath. A shared
assembly is normally stored in the global assembly cache, which
is a repository of assemblies maintained by the .NET runtime.
Shared assemblies are usually libraries of code which many
applications

(B) What is NameSpace?

Namespace has two basic functionality :-


√ NameSpace Logically group types.Example System.Web.UI logically groups
our UI related features.
√ In Object Oriented world may times its possible that programmers will use
the same class name.By qualifying NameSpace with classname this collision
can be removed.

What is .NET Reflection?

.NET Framework’s Reflection API allows you to fetch Type (Assembly) information at
runtime programmatically. We can also achieve the late binding by using .NET
Reflection. At runtime, Reflection mechanism uses the PE file to read the information
about the assembly. Reflection enables you to use code that was not available at
compile time..NET Reflection allows application to collect information about itself and
also manipulate on itself. It can be used effectively to find all the types in an
assembly and/or dynamically invoke methods in an assembly. This includes
information about the type, properties, methods and events of an object. With
reflection we can dynamically create an instance of a type, bind the type to an
existing object, or get the type from an existing object and invoke its methods or
access its fields and properties. We can also access attribute information using
reflection.
(C) What is Difference between NameSpace and Assembly?

Following are the differences between namespace and assembly :

√ Assembly is physical grouping of logical units. Namespace logically


groups classes.

√ Namespace can span multiple assembly.

Create a Visual C# application with threads

1. Start Microsoft Visual Studio .NET, Microsoft Visual Studio 2005, or Microsoft Visual C# 2005 Express
Edition.
2. Create a new Visual C# Windows Application project named ThreadWinApp.
3. Add a Button control to the form. By default, the button is named Button1.
4. Add a ProgressBar component to the form. By default, the progress bar is namedProgressBar1.
5. Right-click the form, and then click View Code.
6. Add the following statement to the beginning of the file:

using System.Threading;

7. Add the following Click event handler for Button1:


8. private void button1_Click(object sender, System.EventArgs e)
9. {
10. MessageBox.Show("This is the main thread");
}

11. Add the following variable to the Form1 class:


12. private Thread trd;
13. Add the following method to the Form1 class:
14. private void ThreadTask()
15. {
16. int stp;
17. int newval;
18. Random rnd=new Random();
19.
20. while(true)
21. {
22. stp=this.progressBar1.Step*rnd.Next(-1,2);
23. newval = this.progressBar1.Value + stp;
24.
25. if (newval > this.progressBar1.Maximum)
26. newval = this.progressBar1.Maximum;
27. else if (newval < this.progressBar1.Minimum)
28. newval = this.progressBar1.Minimum;
29.
30. this.progressBar1.Value = newval;
31.
32. Thread.Sleep(100);
33. }
}

Note This is the code that underlies the thread. This code is an infinite loop that randomly increments
or decrements the value in ProgressBar1, and then waits 100 milliseconds before it continues.

34. Add the following Load event handler for Form1. This code creates a new thread, makes the thread a
background thread, and then starts the thread.
35. private void Form1_Load(object sender, System.EventArgs e)
36. {
37. Thread trd = new Thread(new ThreadStart(this.ThreadTask));
38. trd.IsBackground = true;
39. trd.Start();
}
Back to the top

Verify that it works

1. Build and run the application. Notice that the value in ProgressBar1 changes randomly. This is the
new thread in operation.
2. To demonstrate that the main thread is independent of the thread that changes the value
of ProgressBar1, click the button on the form. You receive a dialog box with the following error
message:

This is the main thread

What is smart navigation?


The cursor position is maintained when the page gets refreshed due to the server
side validation and the page gets refreshed.

Das könnte Ihnen auch gefallen