Click here to Skip to main content
15,899,313 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to use CStringArray in C# using p/invoke Pin
ttcchh200812-Jun-10 3:14
ttcchh200812-Jun-10 3:14 
Questionhow to implement WHITEBOARD for many users Pin
xinxin_52515-Apr-05 23:33
xinxin_52515-Apr-05 23:33 
AnswerRe: how to implement WHITEBOARD for many users Pin
Colin Angus Mackay15-Apr-05 23:48
Colin Angus Mackay15-Apr-05 23:48 
GeneralURI format not supported Pin
Adnan Siddiqi15-Apr-05 22:29
Adnan Siddiqi15-Apr-05 22:29 
GeneralRe: URI format not supported Pin
Heath Stewart16-Apr-05 8:18
protectorHeath Stewart16-Apr-05 8:18 
GeneralRe: URI format not supported Pin
Adnan Siddiqi17-Apr-05 6:00
Adnan Siddiqi17-Apr-05 6:00 
GeneralRe: URI format not supported Pin
Heath Stewart17-Apr-05 16:24
protectorHeath Stewart17-Apr-05 16:24 
GeneralFun with collections... Pin
tantiboh15-Apr-05 22:13
tantiboh15-Apr-05 22:13 
I'm learning how to use C# collections. Can't seem to find the answer on this one, though...

<br />
namespace myNameSpace<br />
{<br />
class ClassA<br />
{<br />
private string key;<br />
private string name;<br />
<br />
//**<br />
//Constructor, property accessors...<br />
//**<br />
}<br />
<br />
class ClassB<br />
{<br />
private HashTable myHashTable;<br />
//I'm encountering the same issues no matter what collection type I use.<br />
<br />
myFunction(string key, string name)<br />
{<br />
myHashTable = new HashTable();<br />
ClassA TempClassA = new ClassA(key, name);<br />
myHashTable.Add(TempClassA.key, TempClassA);<br />
}<br />
<br />
//And now the puzzling part: How to access that instance of ClassA within the<br />
//collection so I can directly access and manipulate the data within it?<br />
//Here's what I'm trying:<br />
<br />
myOtherFuntion(int searchkey)<br />
{<br />
ClassA myClassA = (ClassA)myHashTable[searchkey];<br />
//I need to be able to complete both of the following operations:<br />
string str = myClassA.name; //Causes an exception<br />
myClassA.name = "newname"; //Causes an exception<br />
}<br />
}<br />
}<br />


The code compiles fine. At that point in runtime, however, I get an error referring to "string str = ca.name;" that says "Object reference not set to an instance of an object." The same error occurs for the line "myClassA.name = "newname";". I would imagine it's a fairly basic syntax error, but I just can't find a suitable example.

Any suggestions?

Thanks for your help.
GeneralRe: Fun with collections... Pin
Colin Angus Mackay15-Apr-05 23:37
Colin Angus Mackay15-Apr-05 23:37 
GeneralRe: Fun with collections... Pin
tantiboh16-Apr-05 6:29
tantiboh16-Apr-05 6:29 
GeneralVS.NET 2003 IDE Pin
pmasknguyen15-Apr-05 18:43
pmasknguyen15-Apr-05 18:43 
GeneralRe: VS.NET 2003 IDE Pin
leppie15-Apr-05 21:05
leppie15-Apr-05 21:05 
GeneralWeb Page Generator using C... Pin
ZMAN072815-Apr-05 14:16
ZMAN072815-Apr-05 14:16 
GeneralRe: Web Page Generator using C... Pin
Yulianto.15-Apr-05 16:07
Yulianto.15-Apr-05 16:07 
Questionget size of picture folder?? Pin
Anonymous15-Apr-05 12:58
Anonymous15-Apr-05 12:58 
AnswerRe: get size of picture folder?? Pin
Nicholas Cardi15-Apr-05 13:21
Nicholas Cardi15-Apr-05 13:21 
GeneralAppDomain Question Pin
cobyjone15-Apr-05 12:53
cobyjone15-Apr-05 12:53 
GeneralRe: AppDomain Question Pin
turbochimp15-Apr-05 17:55
turbochimp15-Apr-05 17:55 
GeneralRe: AppDomain Question Pin
cobyjone15-Apr-05 18:19
cobyjone15-Apr-05 18:19 
GeneralRe: AppDomain Question Pin
turbochimp15-Apr-05 19:11
turbochimp15-Apr-05 19:11 
GeneralRe: AppDomain Question Pin
leppie15-Apr-05 21:19
leppie15-Apr-05 21:19 
GeneralReflection problem Pin
Anonymous15-Apr-05 12:23
Anonymous15-Apr-05 12:23 
GeneralRe: Reflection problem Pin
leppie15-Apr-05 21:22
leppie15-Apr-05 21:22 
Generalremoving characters Pin
cishi_us15-Apr-05 11:40
cishi_us15-Apr-05 11:40 
GeneralRe: removing characters Pin
Nicholas Cardi15-Apr-05 11:45
Nicholas Cardi15-Apr-05 11:45 

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.