Click here to Skip to main content
14,975,556 members
Home / Discussions / C#
   

C#

 
GeneralRe: Reuseability of controls Pin
Rafone21-Jun-09 7:58
MemberRafone21-Jun-09 7:58 
GeneralRe: Reuseability of controls Pin
Luc Pattyn21-Jun-09 8:10
sitebuilderLuc Pattyn21-Jun-09 8:10 
QuestionEvent handling in a custom control. Pin
Siddhartha S.21-Jun-09 1:26
MemberSiddhartha S.21-Jun-09 1:26 
AnswerRe: Event handling in a custom control. Pin
Luc Pattyn21-Jun-09 1:58
sitebuilderLuc Pattyn21-Jun-09 1:58 
GeneralRe: Event handling in a custom control. Pin
Siddhartha S.21-Jun-09 16:55
MemberSiddhartha S.21-Jun-09 16:55 
GeneralRe: Event handling in a custom control. Pin
Luc Pattyn21-Jun-09 17:00
sitebuilderLuc Pattyn21-Jun-09 17:00 
GeneralRe: Event handling in a custom control. Pin
Siddhartha S.21-Jun-09 17:04
MemberSiddhartha S.21-Jun-09 17:04 
QuestionCasting KeyValuePair -- eliminate else if blocks [modified] Pin
devvvy21-Jun-09 0:48
Memberdevvvy21-Jun-09 0:48 
hello

Trying to write simpler code... how can I reduce the number of the else-if blocks below?

<br />
if (o is DictionaryEntry)<br />
{<br />
	DictionaryEntry oEntry = (DictionaryEntry)o;<br />
	object oKey = oEntry.Key;<br />
	object oValue = oEntry.Value;<br />
	<br />
	// In this case lstAnotherCollection is a Hashtable<br />
	lstAnotherCollection.Add(oKey, oValue);<br />
	... more ...<br />
}<br />
else if (o is KeyValuePair<string, System.Drawing.Bitmap>)<br />
{<br />
	// This would give error ...<br />
	// KeyValuePair<object, object> oEntry = (KeyValuePair<object, object>)o;<br />
	<br />
	// To resolve this, I resorted to else-elseif blocks (That's obviously undersirable)<br />
	KeyValuePair<string, System.Drawing.Bitmap> oEntry = (KeyValuePair<string, System.Drawing.Bitmap>)o;<br />
	string oKey = oEntry.Key;<br />
	System.Drawing.Bitmap oValue = oEntry.Value;<br />
	<br />
	// lstAnotherCollection = Dictionary<Object, Object><br />
	lstAnotherCollection.Add(oKey, oValue);<br />
	... more ...<br />
}<br />
... many more else-if blocks ...<br />


I suppose I cannot cast KeyValuePair<X,Y> into KeyValuePair<Object, Object> ... because it defeats purpose of Generics in the first place?

Thanks

dev

modified on Sunday, June 21, 2009 6:54 AM

AnswerRe: Casting KeyValuePair -- eliminate else if blocks Pin
Colin Angus Mackay21-Jun-09 3:49
MemberColin Angus Mackay21-Jun-09 3:49 
GeneralRe: Casting KeyValuePair -- eliminate else if blocks Pin
devvvy21-Jun-09 6:15
Memberdevvvy21-Jun-09 6:15 
Question"Error 1053: The service did not respond to the start or control request in a timely fashion" Pin
obrix_activex21-Jun-09 0:37
Memberobrix_activex21-Jun-09 0:37 
QuestionHow You Check Data In DataSet? Pin
noamtzu21-Jun-09 0:17
Membernoamtzu21-Jun-09 0:17 
AnswerRe: How You Check Data In DataSet? Pin
lw@zi 21-Jun-09 0:23
professional lw@zi 21-Jun-09 0:23 
GeneralRe: How You Check Data In DataSet? Pin
noamtzu21-Jun-09 0:32
Membernoamtzu21-Jun-09 0:32 
GeneralRe: How You Check Data In DataSet? Pin
Christian Graus21-Jun-09 0:35
protectorChristian Graus21-Jun-09 0:35 
GeneralRe: How You Check Data In DataSet? Pin
noamtzu21-Jun-09 0:44
Membernoamtzu21-Jun-09 0:44 
GeneralRe: How You Check Data In DataSet? Pin
Rajesh R Subramanian21-Jun-09 6:03
professionalRajesh R Subramanian21-Jun-09 6:03 
GeneralRe: How You Check Data In DataSet? Pin
EliottA22-Jun-09 2:49
MemberEliottA22-Jun-09 2:49 
QuestionStrange Dataset problem! [modified] Pin
Muammar©20-Jun-09 22:39
Member Muammar©20-Jun-09 22:39 
AnswerRe: Strange Dataset problem! Pin
Mycroft Holmes20-Jun-09 23:15
professionalMycroft Holmes20-Jun-09 23:15 
AnswerSolved! Pin
Muammar©20-Jun-09 23:24
Member Muammar©20-Jun-09 23:24 
QuestionGDI+, problem with Invalidate() method Pin
cppwxwidgetsss20-Jun-09 21:16
Membercppwxwidgetsss20-Jun-09 21:16 
AnswerRe: GDI+, problem with Invalidate() method Pin
Christian Graus21-Jun-09 0:37
protectorChristian Graus21-Jun-09 0:37 
AnswerRe: GDI+, problem with Invalidate() method Pin
OriginalGriff21-Jun-09 0:50
mveOriginalGriff21-Jun-09 0:50 
Questionautocomplete selection Pin
Iain Wiseman20-Jun-09 19:33
MemberIain Wiseman20-Jun-09 19:33 

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.