Click here to Skip to main content
15,891,136 members
Home / Discussions / C#
   

C#

 
AnswerRe: Using Regex to find a Match Pin
OriginalGriff7-Oct-09 2:57
mveOriginalGriff7-Oct-09 2:57 
AnswerRe: Using Regex to find a Match Pin
PIEBALDconsult7-Oct-09 4:34
mvePIEBALDconsult7-Oct-09 4:34 
QuestionGo back to old file path after open file dialog box Pin
AhmedMasum7-Oct-09 2:18
AhmedMasum7-Oct-09 2:18 
AnswerRe: Go back to old file path after open file dialog box Pin
stancrm7-Oct-09 2:23
stancrm7-Oct-09 2:23 
GeneralRe: Go back to old file path after open file dialog box Pin
AhmedMasum7-Oct-09 3:32
AhmedMasum7-Oct-09 3:32 
GeneralRe: Go back to old file path after open file dialog box Pin
stancrm7-Oct-09 20:43
stancrm7-Oct-09 20:43 
AnswerRe: Go back to old file path after open file dialog box Pin
Nagy Vilmos7-Oct-09 3:26
professionalNagy Vilmos7-Oct-09 3:26 
QuestionUsing foreach to run thru an arraylist containing a struct Pin
Kyle Wood7-Oct-09 0:58
Kyle Wood7-Oct-09 0:58 
I have the following code extract:

public arraylist myList = new arraylist();<br />
public struct myDBList<br />
{<br />
  public string strKey;<br />
  public string strName;<br />
  public string strDataSetName;<br />
}


I loop thru a list of databases and add data from each to my list:

foreach (database db in dbList)<br />
{<br />
  myDBList.strKey = db.Key.ToString();<br />
  myDBList.strActual = db.Name.ToFriendlyString();<br />
  myDBList.strDataSetName = db.Path.ToFriendlyString();<br />
  myList.Add(myDBList);<br />
}


this arraylist is then passed to a 2nd form with:

Form myLogon = new Form();<br />
myLogon.passedList = myList;


In the 2nd form I have declared the same arraylist & struct and I want to loop thru the list and extract the data so I use:

ArrayList newList = new ArrayList();<br />
public struct myDBList<br />
{<br />
  public string strKey;<br />
  public string strName;<br />
  public string strDataSetName;<br />
}<br />
string key;<br />
<br />
public arraylist passedList<br />
{<br />
  get{ newList = value; }<br />
}


and in the code:

foreach( dbList db in newList)<br />
{<br />
  key = db.strKey;<br />
  .<br />
  .<br />
}


While the code compiles, when I come to execute the foreach statement i get the error:

InvalidCastException was unhandled - specified cast is not valid

What am I doing wrong here ??
AnswerRe: Using foreach to run thru an arraylist containing a struct Pin
J4amieC7-Oct-09 1:10
J4amieC7-Oct-09 1:10 
GeneralRe: Using foreach to run thru an arraylist containing a struct Pin
Kyle Wood7-Oct-09 2:38
Kyle Wood7-Oct-09 2:38 
QuestionSet ID and value to a treeview node Pin
yesu prakash7-Oct-09 0:55
yesu prakash7-Oct-09 0:55 
AnswerRe: Set ID and value to a treeview node Pin
Henry Minute7-Oct-09 2:36
Henry Minute7-Oct-09 2:36 
QuestionGet checked child nodes from tree view Pin
yesu prakash7-Oct-09 0:33
yesu prakash7-Oct-09 0:33 
AnswerRe: Get checked child nodes from tree view Pin
stancrm7-Oct-09 0:37
stancrm7-Oct-09 0:37 
Questiondatagrid textbox cell Pin
Member 5903106-Oct-09 23:48
Member 5903106-Oct-09 23:48 
AnswerRe: datagrid textbox cell Pin
Henry Minute7-Oct-09 2:30
Henry Minute7-Oct-09 2:30 
GeneralRe: datagrid textbox cell Pin
Member 5903107-Oct-09 22:32
Member 5903107-Oct-09 22:32 
GeneralRe: datagrid textbox cell Pin
Henry Minute8-Oct-09 4:12
Henry Minute8-Oct-09 4:12 
QuestionAsynchronous methods - callback method is never called Pin
lvq6846-Oct-09 23:47
lvq6846-Oct-09 23:47 
QuestionHelp Streaming Video Pin
amaankhan6-Oct-09 22:30
amaankhan6-Oct-09 22:30 
Answerwhat ? Pin
Christian Graus6-Oct-09 22:32
protectorChristian Graus6-Oct-09 22:32 
GeneralRe: what ? Pin
amaankhan6-Oct-09 22:37
amaankhan6-Oct-09 22:37 
GeneralRe: what ? Pin
Christian Graus6-Oct-09 23:35
protectorChristian Graus6-Oct-09 23:35 
GeneralRe: what ? Pin
EliottA7-Oct-09 2:08
EliottA7-Oct-09 2:08 
AnswerRe: Help Streaming Video Pin
Saksida Bojan6-Oct-09 22:37
Saksida Bojan6-Oct-09 22:37 

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.