Click here to Skip to main content
15,920,111 members
Home / Discussions / C#
   

C#

 
Questioncreating a tile pattern of user controls Pin
ideasman3-Aug-08 3:07
ideasman3-Aug-08 3:07 
AnswerRe: creating a tile pattern of user controls Pin
PIEBALDconsult3-Aug-08 5:57
mvePIEBALDconsult3-Aug-08 5:57 
GeneralRe: creating a tile pattern of user controls Pin
ideasman3-Aug-08 11:45
ideasman3-Aug-08 11:45 
GeneralRe: creating a tile pattern of user controls Pin
PIEBALDconsult3-Aug-08 11:56
mvePIEBALDconsult3-Aug-08 11:56 
GeneralRe: creating a tile pattern of user controls Pin
ideasman3-Aug-08 21:05
ideasman3-Aug-08 21:05 
AnswerRe: creating a tile pattern of user controls Pin
nelsonpaixao3-Aug-08 15:10
nelsonpaixao3-Aug-08 15:10 
AnswerRe: creating a tile pattern of user controls Pin
Mycroft Holmes3-Aug-08 15:48
professionalMycroft Holmes3-Aug-08 15:48 
GeneralRe: creating a tile pattern of user controls Pin
ideasman3-Aug-08 21:14
ideasman3-Aug-08 21:14 
GeneralRe: creating a tile pattern of user controls Pin
Mycroft Holmes3-Aug-08 21:22
professionalMycroft Holmes3-Aug-08 21:22 
GeneralRe: creating a tile pattern of user controls Pin
ideasman3-Aug-08 23:07
ideasman3-Aug-08 23:07 
Questionc# and implementing security Pin
Ryan Minor3-Aug-08 2:19
Ryan Minor3-Aug-08 2:19 
AnswerRe: c# and implementing security Pin
Kevin McFarlane3-Aug-08 5:01
Kevin McFarlane3-Aug-08 5:01 
AnswerRe: c# and implementing security Pin
nelsonpaixao3-Aug-08 15:17
nelsonpaixao3-Aug-08 15:17 
Questionconnecting to excel 2007 Pin
Abdul Rahman Hamidy3-Aug-08 2:02
Abdul Rahman Hamidy3-Aug-08 2:02 
AnswerRe: connecting to excel 2007 Pin
MarkB7773-Aug-08 14:44
MarkB7773-Aug-08 14:44 
QuestionRegular expressions: Show matches [modified] Pin
MyPiano3-Aug-08 2:00
MyPiano3-Aug-08 2:00 
AnswerRe: Regular expressions: Show matches Pin
Nicholas Butler3-Aug-08 2:52
sitebuilderNicholas Butler3-Aug-08 2:52 
GeneralRe: Regular expressions: Show matches Pin
MyPiano3-Aug-08 3:13
MyPiano3-Aug-08 3:13 
AnswerRe: Regular expressions: Show matches Pin
Guffa3-Aug-08 3:37
Guffa3-Aug-08 3:37 
GeneralRe: Regular expressions: Show matches Pin
MyPiano3-Aug-08 3:40
MyPiano3-Aug-08 3:40 
QuestionDataGridView scrolling? Pin
kbalias2-Aug-08 22:19
kbalias2-Aug-08 22:19 
AnswerRe: DataGridView scrolling? Pin
Mycroft Holmes2-Aug-08 22:47
professionalMycroft Holmes2-Aug-08 22:47 
GeneralRe: DataGridView scrolling? Pin
kbalias2-Aug-08 22:55
kbalias2-Aug-08 22:55 
GeneralRe: DataGridView scrolling? Pin
Mycroft Holmes3-Aug-08 2:25
professionalMycroft Holmes3-Aug-08 2:25 
QuestionChallenge for C# guru's Pin
MarkB7772-Aug-08 21:50
MarkB7772-Aug-08 21:50 
Well I hope its a challenge or i'm going to look stupid...

I've got some code (below) that is looking really ugly, but i'm not sure how ot simplify it. Ive posted a small portion of it, but there are approx 20 of these "if" blocks.

The variable "record" is a structure (and all its members are strings), and Fields in an enum (int). (If you need it, grid is a 2D object array, and fields is a dictionary)

Anyone have any idea's on how to compact this code?

<br />
            char value;<br />
            if (this.fields.TryGetValue((int)Fields.COMPANY, out value)) <br />
                record.company = grid[1, (int)value - 64].ToString();<br />
<br />
            if (this.fields.TryGetValue((int)Fields.EMAIL, out value))<br />
                record.email = grid[1, (int)value - 64].ToString();<br />
<br />
            if (this.fields.TryGetValue((int)Fields.FAX, out value))<br />
                record.fax = grid[1, (int)value - 64].ToString();<br />
<br />
            if (this.fields.TryGetValue((int)Fields.FIRSTNAME, out value))<br />
                record.firstName = grid[1, (int)value - 64].ToString();<br />
<br />



Cheers,


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.