|
-
October 12th, 2012 09:46 AM
#1
Typecasting Object to Struct.
I have a linked list that takes any object, and puts it a struct with some other params:
Let's say:
public VList(Object Data);
passes it to
public struct VData
{
public double ID;
public Object Data;
}
So when you want to retreive it you create a struct, pass it as a ref, and take the struct.data part.
Lets say:
struct Vals
{
public string a;
public string b;
public string c;
public string d;
}
[ creating instances and stuff]
List.Add(vals);
List.Find(id, ref vdata);
vals = (Vals) vdata.Data;
THis actually worked till I changed some code on the list's library (not really had to do with all these).
Now it sends an InvalidCastException like "Specified cast is not valid."
What's wrong with it?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Click Here to Expand Forum to Full Width
|
Bookmarks