Implement hash table with only primitive data types in ASP.Net using C# and VB.Net

seriverma
 
on May 16, 2021 11:07 PM
Sample_544429.zip
1584 Views

can you please help any one answers for below questions

1. Assuming we are now using a framework/SDK that is without Hash table, please describe how we can implement a hash table with using only primitive data types. You may start be describing what are the main features required by a simple hash table and the suggested solution.

2. If we would like to dynamically load a library file (C#: *.dll / JAVA: *.jar) during runtime and overriding some of the current functions, how to do that?

3. In a multi-threaded application, we started multiple threads at the same time. Then, how to block the application execution until all threads complete the execution? (we do not want the thread to be executed in sequential order, we want the thread to fully utilize the CPU resources.)

4. Please suggest a way that can do inter-process communication with another process, not limited to .Net process.

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on May 17, 2021 02:58 AM
on May 17, 2021 02:58 AM

Hi seriverma,

Refer below code of hash table.

The primitive data types are int, object, short, char, float, double, bool.

Code

C#

protected void Page_Load(object sender, EventArgs e)
{
    object key1 = "Name";
    object name = "Dharmendra";

    object key2 = "Age";
    object age = 31;

    System.Collections.Hashtable ht = new System.Collections.Hashtable();
    ht.Add(key1, name);
    ht.Add(key2, age);
    System.Collections.ICollection keys = ht.Keys;
    string message = "";
    foreach (string key in keys)
    {
        message += string.Format("{0} : {1}<br/>", key, ht[key]);
    }
    Response.Write(message);
}

VB.Net

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    Dim key1 As Object = "Name"
    Dim name As Object = "Dharmendra"
    Dim key2 As Object = "Age"
    Dim age As Object = 31
    Dim ht As System.Collections.Hashtable = New System.Collections.Hashtable()
    ht.Add(key1, name)
    ht.Add(key2, age)
    Dim keys As System.Collections.ICollection = ht.Keys
    Dim message As String = ""

    For Each key As String In keys
        message += String.Format("{0} : {1}<br/>", key, ht(key))
    Next

    Response.Write(message)
End Sub

Screenshot

Dynamic load dll

https://stackoverflow.com/questions/18362368/loading-dlls-at-runtime-in-c-sharp

Multi thread

https://stackoverflow.com/questions/33484341/c-sharp-net-how-to-make-application-wait-until-all-threads-created-in-library

Inter-process communication

https://stackoverflow.com/questions/528652/what-is-the-simplest-method-of-inter-process-communication-between-2-c-sharp-pro