Click here to Skip to main content
15,921,905 members
Home / Discussions / C#
   

C#

 
GeneralRe: RichTextBox question.. Pin
Fredrik7925-Jan-04 5:58
Fredrik7925-Jan-04 5:58 
GeneralRe: RichTextBox question.. Pin
Nick Parker25-Jan-04 7:41
protectorNick Parker25-Jan-04 7:41 
Generalchecking dynamically which control is clicked Pin
Inam24-Jan-04 6:41
Inam24-Jan-04 6:41 
GeneralRe: checking dynamically which control is clicked Pin
Alex Korchemniy24-Jan-04 6:56
Alex Korchemniy24-Jan-04 6:56 
GeneralRe: checking dynamically which control is clicked Pin
Dmitriy Kostovetskiy24-Jan-04 13:32
Dmitriy Kostovetskiy24-Jan-04 13:32 
GeneralIgnore Keyboard And mouse input Pin
SherKar24-Jan-04 2:31
SherKar24-Jan-04 2:31 
GeneralRe: Ignore Keyboard And mouse input Pin
Mazdak24-Jan-04 3:09
Mazdak24-Jan-04 3:09 
GeneralTrouble extracting objects from HashTable Pin
Peter Mills24-Jan-04 1:51
Peter Mills24-Jan-04 1:51 
I've got a bit of an obscure problem extracting my objects from a HashTable. The basic idea is that the hashtable is populated with objects - which are classes of UTServer. UTServer is a class that contains various variables and a single method - refresh(). I also need to use a hashtable because of the key it uses (since I have to link my hashtable to a listview later on and want it to be as fast as possible)

I don't appear to have any trouble adding the UTServer classes into the hashtable. However getting these out and reading the variables held inside is proving to be difficult.

My Code as follows:

//Declaring the hashtable publicly
Hashtable servers = new Hashtable();



//Adding a UTServer into the hashtable

UTServer myServer = new UTServer();
myServer.ip = "192.168.0.1"
myServer.port = "7777";
myServer.queryOffset = "10";
myServer.game = "ut";
myServer.serverID = 1;
servers.Add(myServer.serverID, myServer);


(when counting the objects in servers - it returns the correct amount)


//UTServer class that is added into the hashtable
public class UTServer
{
public String ip = "";
public String port = "";
public String queryOffset = "";
public String game = "";
public long serverID;
public UT2003Server remoteServer = new UT2003Server();

public void Refresh()
{
remoteServer.Ip = ip;
remoteServer.Port = int.Parse(port);
remoteServer.Protocol = UT2003Server.QueryProtocol.Mixed;

remoteServer.Refresh(game);
}
}



//My code that doesn't work

object obj1 = servers[1];
UTServer b = new UTServer();
b = (UTServer) obj1;
MessageBox.Show(b.ip);


(it should in the messagebox show the ip "192.168.0.1" however it gives a null pointer exception instead.


I would greatly appreciate any advice anyone has, thank you.

Peter


GeneralRe: Trouble extracting objects from HashTable Pin
Colin Angus Mackay24-Jan-04 4:11
Colin Angus Mackay24-Jan-04 4:11 
GeneralRe: Trouble extracting objects from HashTable Pin
Peter Mills24-Jan-04 4:48
Peter Mills24-Jan-04 4:48 
GeneralAdding scaner funtionality to C# application Pin
Chathura23-Jan-04 12:34
Chathura23-Jan-04 12:34 
GeneralRe: Adding scaner funtionality to C# application Pin
Heath Stewart23-Jan-04 18:02
protectorHeath Stewart23-Jan-04 18:02 
GeneralRe: Adding scaner funtionality to C# application Pin
cjengler24-Jan-04 2:25
cjengler24-Jan-04 2:25 
QuestionWhat is a cheap compiler for C#. Pin
Snyp23-Jan-04 12:10
Snyp23-Jan-04 12:10 
AnswerRe: What is a cheap compiler for C#. Pin
Colin Angus Mackay23-Jan-04 12:44
Colin Angus Mackay23-Jan-04 12:44 
AnswerRe: What is a cheap compiler for C#. Pin
Guillermo Rivero23-Jan-04 17:35
Guillermo Rivero23-Jan-04 17:35 
AnswerRe: What is a cheap compiler for C#. Pin
Heath Stewart23-Jan-04 18:00
protectorHeath Stewart23-Jan-04 18:00 
GeneralRe: What is a cheap compiler for C#. Pin
OmegaSupreme25-Jan-04 3:38
OmegaSupreme25-Jan-04 3:38 
AnswerRe: What is a cheap compiler for C#. Pin
extremeg24-Jan-04 3:06
extremeg24-Jan-04 3:06 
General.Net Remoting store serialization file Pin
krisp23-Jan-04 11:23
krisp23-Jan-04 11:23 
GeneralRe: .Net Remoting store serialization file Pin
Heath Stewart23-Jan-04 18:22
protectorHeath Stewart23-Jan-04 18:22 
GeneralRe: .Net Remoting store serialization file Pin
krisp23-Jan-04 19:06
krisp23-Jan-04 19:06 
GeneralRe: .Net Remoting store serialization file Pin
Heath Stewart23-Jan-04 19:14
protectorHeath Stewart23-Jan-04 19:14 
GeneralRe: .Net Remoting store serialization file Pin
krisp24-Jan-04 13:36
krisp24-Jan-04 13:36 
GeneralRe: .Net Remoting store serialization file Pin
Heath Stewart23-Jan-04 18:24
protectorHeath Stewart23-Jan-04 18:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.