Beruflich Dokumente
Kultur Dokumente
Mono Project
The PE file format was defined to provide the best way for the
Windows Operating System to execute code and also to store the
essential data which is needed to run a program. Portable
Executable File Format is derived from the Microsoft Common
Object File Format (COFF).
Managed Code
Managed Code in Microsoft .Net Framework, is the code that has
executed by the Common Language Runtime (CLR) environment.
On the other hand Unmanaged Code is directly executed by the
computer's CPU. Data types, error-handling mechanisms, creation
and destruction rules, and design guidelines vary between managed
and unmanaged object models.
1. Private Assembly
2. Shared Assembly
The GAC is automatically installed with the .NET runtime. The global
assembly cache is located in 'Windows/WinNT' directory and inherits
the directory's access control list that administrators have used to
protect the folder.
gacutil -l or gacutil /l
The classes that ship with the .NET Framework are all built as
shared assemblies.
sn -k fileName
In this command, file name is the name of the output file containing
the key pair.
Each application running within its main process boundaries and its
application domain boundaries. All objects created within the same
application scope are created within the same application domain.
Multiple application domains can exist in a single operating system
process. An application running inside one application domain
cannot directly access the code running inside another application
domain.
.Net Threading
Thread in computer science means a sequence of execution
instructions that can run independently , that is a single flow of
execution in a process. Thread is like a process, at least one thread
exists within each process. Single Thread (normal programs) in
computer science means that only one task can execute and at the
same time the other tasks have to wait for the completion of the
current task like in a queue. Single thread resulted in systems idle
time and application performance.
VB.NET Collections
Visual Basic supports a number of data structures called Collections
that holds data in different ways for flexible operations. The
important data structures in the Collection Classes
are ArrayList , HashTable , Stack , Queue etc. From the following
chapters you can see how to manage these data structures in your
visual Basic.net programs.
How to VB.NET ArrayList
ArrayList is one of the most flexible data structure from VB.NET
Collections. With the Array list you can add elements to your array
dynamically and it accepts null as a valid value and also allows
duplicate elements. Normally Collection class allow you to access an
item using either a numeric index or a String key, but ArrayList
allows only a numeric index. ArrayList is flexible because we can
add items without any size information.
Syntax : ArrayList.add(Item)
ItemList.Add("Item4")
Syntax : ArrayList.insert(index,item)
ItemList.Insert(3, "item6")
Syntax : ArrayList.Remove(item)
ItemList.Remove("item2")
Syntax : ArrayList.RemoveAt(index)
ItemList.RemoveAt(2)
Syntax : ArrayListSort()
From the following Visual Basic source code you can see some
important operations from an ArrayList Object
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim ItemList As New ArrayList()
ItemList.Add("Item4")
ItemList.Add("Item5")
ItemList.Add("Item2")
ItemList.Add("Item1")
ItemList.Add("Item3")
MsgBox("Shows Added Items")
For i = 0 To ItemList.Count - 1
MsgBox(ItemList.Item(i))
Next
'insert an item
ItemList.Insert(3, "Item6")
'sort itemms in an arraylist
ItemList.Sort()
'remove an item
ItemList.Remove("Item1")
'remove item from a specified index
ItemList.RemoveAt(3)
MsgBox("Shows final Items the ArrayList")
For i = 0 To ItemList.Count - 1
MsgBox(ItemList.Item(i))
Next
End Sub
End Class
Syntax : HashTable.Add(Key,Value)
Synatx : HashTable.ContainsKey(key)
Synatx : HashTable.ContainsValue(Value)
Syntax : HashTable.Remove(Key)
Key : The argument key of deleting pairs
Syntax : Stack.Pop()
Syntax : Stack.Contains(Object)
Syntax : Stack.Enqueue(Object)
Dequeue : Remove the oldest item from Queue (we dont get
the item later)
Syntax : Stack.Dequeue()
Peek : Get the reference of the oldest item (it is not removed
permenantly)
Syntax : Stack.Peek()
Integer Array
array(0) = 10
array(1) = 20
array(2) = 30
array(3) = 40
Note that in the above code we did not specify the length of the
array so the compiler will do it for us.
array.Length
String Array
week(0) = "Sunday"
week(1) = "Monday"
This method should be used with only one dimensional Array. This
method allocates a new array with the specified size, copies
elements from the old array to the new one, and then replaces the
old array with the new one.
Array.Resize(sArray, 3)
Array Sort
You can create an array with elements of different data types when
declare the array as Object. Since System.Object is the base class
of all other types, an item in an array of Objects can have a
reference to any other type of object. More about.... Multiple data
types in an Array - VB.Net
Initial declaration
Resizing
ReDim scores(1)
If you want to keep the existing items in the Array , you can use the
keyword Preserve .
In this case the Array dynamically allocate one more String value
and keep the existing values.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim scores() As Integer
ReDim scores(1)
scores(0) = 100
scores(1) = 200
For i = 0 To scores.Length - 1
MsgBox(scores(i))
Next
scores(2) = 300
For i = 0 To scores.Length - 1
MsgBox(scores(i))
Next
End Sub
End Class
Add("High","80")
End Sub
End Class
List(Of T)
numbers.Count
You can retrieve items from List collection by using for loops.
foreach loop
for loop
numbers.Insert(1, "zero")
In the above code the number "zero" is inserted in the index
position 1.
numbers.Remove("zero");
if (numbers.Contains("Two"))
{
MessageBox.Show("Number Two exist in the list");
}
Finally clear method remove all the items from List collection.
arrlist.Clear()
If numbers.Contains("Two") Then
MessageBox.Show("Number two exist in the list")
Else
MessageBox.Show("Not exist")
End If
MessageBox.Show(arrlist.Count.ToString())
End Sub
End Class
Dictionary in vb.net
How to VB.Net Dictionary
Syntax:
Parameters :
e.g.
Add method in Dictionary takes two parameters, one for the key
and one for the value.
Syntax:
e.g.
dictionary.Add("dozen",12)
Key in a Dictionary should not be null, but a value can be, if TValue
is a reference type.