Click here to Skip to main content
15,887,676 members
Home / Discussions / C#
   

C#

 
QuestionForm Inheritance Pin
PHDENG814-Oct-05 2:08
PHDENG814-Oct-05 2:08 
AnswerRe: Form Inheritance Pin
spif20014-Oct-05 2:10
spif20014-Oct-05 2:10 
GeneralRe: Form Inheritance Pin
PHDENG814-Oct-05 2:21
PHDENG814-Oct-05 2:21 
GeneralRe: Form Inheritance Pin
PHDENG814-Oct-05 2:31
PHDENG814-Oct-05 2:31 
GeneralRe: Form Inheritance Pin
spif20014-Oct-05 2:32
spif20014-Oct-05 2:32 
Questionhi all Pin
magnifique4-Oct-05 1:44
magnifique4-Oct-05 1:44 
AnswerRe: hi all Pin
Guffa4-Oct-05 2:06
Guffa4-Oct-05 2:06 
QuestionDeriving a class variable from a string Pin
MrEyes4-Oct-05 1:39
MrEyes4-Oct-05 1:39 
I have to admit its an odd thread title, but it almost describes what I want to do.

Let say I have the following class

class Duck
{
 public string name;
 public int age;
 public bool isMale;
}


I need to be able to access these class vars from strings. Lets say I have the following instance of the Duck class

Duck myDuck = new Duck();
myDuck.name = "fred";
myDuck.age = "2";
myDuck.isMale = false;


Elsewhere in the code I have the following strings, and I need to use these strings to access the member variables of the myDuck instance. I know this could be done with if/else/switch etc but I am curious to learn if there is a way to do this with less code.

string varName_DuckName = "name";
int varName_DuckAge = "age";
bool varName_duckIsMale = "isMale";


And example (ish) of what I want to do already exists in the .NET framework for the Color class where you can call:

Color.FromName("red")

So I would like to be able to do something like

bool b = (bool)myDuck.FromName("isMale")

Which is the case of the example above would set b as false

post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
AnswerRe: Deriving a class variable from a string Pin
Robert Rohde4-Oct-05 2:05
Robert Rohde4-Oct-05 2:05 
QuestionStandard Deviation Graph?? Pin
parvinder sehrawat4-Oct-05 1:34
parvinder sehrawat4-Oct-05 1:34 
QuestionHandling .class files in C# Pin
Dsypher4-Oct-05 1:07
Dsypher4-Oct-05 1:07 
AnswerRe: Handling .class files in C# Pin
g00fyman4-Oct-05 3:19
g00fyman4-Oct-05 3:19 
AnswerRe: Handling .class files in C# Pin
Daniel Grunwald4-Oct-05 5:56
Daniel Grunwald4-Oct-05 5:56 
Questionbuild a forum Pin
Venkat60704-Oct-05 0:50
Venkat60704-Oct-05 0:50 
AnswerRe: build a forum Pin
ehuysamer4-Oct-05 4:05
ehuysamer4-Oct-05 4:05 
Questionshowing data in datagrid from two relational tables Pin
Rizwan Bashir4-Oct-05 0:50
Rizwan Bashir4-Oct-05 0:50 
AnswerRe: showing data in datagrid from two relational tables Pin
Robert Rohde4-Oct-05 1:17
Robert Rohde4-Oct-05 1:17 
QuestionError creating .exe Pin
sean_mufc4-Oct-05 0:42
sean_mufc4-Oct-05 0:42 
QuestionReplace a block of text file Pin
Bharath KR4-Oct-05 0:38
Bharath KR4-Oct-05 0:38 
AnswerRe: Replace a block of text file Pin
Robert Rohde4-Oct-05 1:33
Robert Rohde4-Oct-05 1:33 
QuestionRe: Replace a block of text file Pin
Sean Michael Murphy4-Oct-05 3:26
Sean Michael Murphy4-Oct-05 3:26 
AnswerRe: Replace a block of text file Pin
Bharath KR4-Oct-05 3:48
Bharath KR4-Oct-05 3:48 
QuestionReturning Custom Errors from a custom Action in Deployment projects Pin
lata07mahi4-Oct-05 0:02
lata07mahi4-Oct-05 0:02 
QuestionProblem with DataAdapter and DataSet Pin
kbalias3-Oct-05 23:18
kbalias3-Oct-05 23:18 
AnswerRe: Problem with DataAdapter and DataSet Pin
Guffa3-Oct-05 23:44
Guffa3-Oct-05 23:44 

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.