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

C#

 
GeneralRe: how to add object to listview Pin
Not Active12-Feb-08 16:48
mentorNot Active12-Feb-08 16:48 
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 
Hi Jeff,

you should try not to rely on type names, since doing so will fail for derived types.
The way to go most often is using the "is" or "as" keywords, as in:

if (obj is Font) {
    ... do someting fonty (probably will need a cast)
} else if (obj is Panel) {
    ... deal with a Panel (probably will need a cast)
} etc.


or

Font fnt=obj as Font;  // generates null if obj isn't a Font
if (fnt!=null) {
   ... do someting fonty to fnt (no extra cast required)
}
Panel pan=obj as Panel;
if (pan!=null) {
    ...
}


The above will also match mySpecialPanel and the like, something typename-dependent code
would typically not do.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.


AnswerRe: NameOf method? Pin
Roger Alsing12-Feb-08 22:00
Roger Alsing12-Feb-08 22:00 
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 

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.