Click here to Skip to main content
15,919,613 members
Home / Discussions / C#
   

C#

 
QuestionNameOf method? Pin
Skippums12-Feb-08 7:40
Skippums12-Feb-08 7:40 
AnswerRe: NameOf method? Pin
Eslam Afifi12-Feb-08 8:12
Eslam Afifi12-Feb-08 8:12 
GeneralRe: NameOf method? Pin
Ravenet12-Feb-08 14:41
Ravenet12-Feb-08 14:41 
GeneralRe: NameOf method? Pin
Eslam Afifi13-Feb-08 2:32
Eslam Afifi13-Feb-08 2:32 
AnswerRe: NameOf method? Pin
TJoe12-Feb-08 8:13
TJoe12-Feb-08 8:13 
AnswerRe: NameOf method? Pin
Not Active12-Feb-08 8:14
mentorNot Active12-Feb-08 8:14 
AnswerRe: NameOf method? Pin
Luc Pattyn12-Feb-08 14:41
sitebuilderLuc Pattyn12-Feb-08 14:41 
AnswerRe: NameOf method? Pin
Roger Alsing12-Feb-08 22:00
Roger Alsing12-Feb-08 22:00 
You could also use some lookup pattern.

setup type -> action association
Dictionary<type, somedelegate> myLookup = new .....
myLookup.Add(typeof(string) , () => MessageBox.Show("Its a string!"));
myLookup.Add(typeof(int) , () => Console.WriteLine("ooh an int.."));


and then replace your switch/if with:

------
SomeDelegate action;
if (myLookup.TryGetValue( a.GetType() , out action ) )
{
    //there is a delegate associated with this type:
    action(); //execute the action
}
----

So you replace your switch/if completely with the lines above...
But it depends on what you actually want to accomplish.
See the post above mine regarding subclasses.


GeneralAngle between two vectors Pin
Hami.Net12-Feb-08 7:00
Hami.Net12-Feb-08 7:00 
GeneralRe: Angle between two vectors Pin
Giorgi Dalakishvili12-Feb-08 7:17
mentorGiorgi Dalakishvili12-Feb-08 7:17 
GeneralRe: Angle between two vectors Pin
Eslam Afifi12-Feb-08 7:20
Eslam Afifi12-Feb-08 7:20 
AnswerRe: Angle between two vectors Pin
Spacix One12-Feb-08 7:20
Spacix One12-Feb-08 7:20 
QuestionHow to execute a gawk script in a c# aplication Pin
pcaeiro12-Feb-08 6:17
pcaeiro12-Feb-08 6:17 
AnswerRe: How to execute a gawk script in a c# aplication Pin
KaptinKrunch12-Feb-08 6:26
KaptinKrunch12-Feb-08 6:26 
Questionhow to access the data of MS word from c#.net 2005 Pin
shining12-Feb-08 5:56
shining12-Feb-08 5:56 
AnswerRe: how to access the data of MS word from c#.net 2005 Pin
Giorgi Dalakishvili12-Feb-08 6:24
mentorGiorgi Dalakishvili12-Feb-08 6:24 
AnswerRe: how to access the data of MS word from c#.net 2005 Pin
KaptinKrunch12-Feb-08 6:24
KaptinKrunch12-Feb-08 6:24 
GeneralRe: how to access the data of MS word from c#.net 2005 Pin
shining13-Feb-08 3:48
shining13-Feb-08 3:48 
AnswerRe: how to access the data of MS word from c#.net 2005 Pin
Ravenet12-Feb-08 14:45
Ravenet12-Feb-08 14:45 
GeneralRe: how to access the data of MS word from c#.net 2005 Pin
shining13-Feb-08 3:46
shining13-Feb-08 3:46 
GeneralRe: how to access the data of MS word from c#.net 2005 Pin
Ravenet13-Feb-08 3:58
Ravenet13-Feb-08 3:58 
GeneralSpeech Recognation Pin
faisalid200012-Feb-08 5:38
faisalid200012-Feb-08 5:38 
GeneralRe: Speech Recognation Pin
Justin Perez12-Feb-08 5:48
Justin Perez12-Feb-08 5:48 
GeneralRe: Speech Recognation Pin
faisalid200012-Feb-08 5:58
faisalid200012-Feb-08 5:58 
GeneralRe: Speech Recognation Pin
Justin Perez12-Feb-08 6:00
Justin Perez12-Feb-08 6:00 

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.