Click here to Skip to main content
15,890,527 members
Home / Discussions / C#
   

C#

 
GeneralRe: Switch-Case sample Pin
OriginalGriff22-May-18 4:19
mveOriginalGriff22-May-18 4:19 
GeneralRe: Switch-Case sample Pin
Dave Kreskowiak22-May-18 4:26
mveDave Kreskowiak22-May-18 4:26 
GeneralRe: Switch-Case sample Pin
OriginalGriff22-May-18 5:37
mveOriginalGriff22-May-18 5:37 
GeneralRe: Switch-Case sample Pin
Mycroft Holmes22-May-18 14:13
professionalMycroft Holmes22-May-18 14:13 
AnswerRe: Switch-Case sample Pin
OriginalGriff22-May-18 22:59
mveOriginalGriff22-May-18 22:59 
GeneralRe: Switch-Case sample Pin
User 1367511422-May-18 23:23
User 1367511422-May-18 23:23 
GeneralRe: Switch-Case sample Pin
Pete O'Hanlon22-May-18 23:40
mvePete O'Hanlon22-May-18 23:40 
AnswerRe: Switch-Case sample Pin
#realJSOP24-May-18 3:35
mve#realJSOP24-May-18 3:35 
Why couldn't you simply set some variables in the Checked handler, which would make the switch statement irrelevant?

C#
Paragraph q1 = null;

public void radio54_ischecked(...)
{
    this.q1 = new Paragraph(string.Format("{0} {1}", label10Text, radioButton54.Text));
}
public void radio22_ischecked(...)
{
    this.q1 = new Paragraph(string.Format("{0} {1}", label10Text, radioButton22.Text));
}
public void radio1_ischecked(...)
{
    this.q1 = new Paragraph(string.Format("{0} {1}", label10Text, radioButton1.Text));
}


at that point, switch statement could be removed and replaced with this line of code, because q1 would already be ready (or null, depending on how your code is written):

C#
if (q1 != null) pdfDosya.Add(q1);


EDIT ==================================

There are ways you can further reduce the code in the checked event handlers (depending on what framework you're dealing with), but I'll leave that as an exercise for the programmer.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013


modified 24-May-18 14:55pm.

QuestionHow to insert image into merged cell. (ClosedXML) Pin
Member 1379545720-May-18 14:11
Member 1379545720-May-18 14:11 
SuggestionRe: How to insert image into merged cell. (ClosedXML) Pin
Maciej Los21-May-18 20:41
mveMaciej Los21-May-18 20:41 
QuestionTriggering a cellformatting event of a datagridview Pin
leone19-May-18 10:21
leone19-May-18 10:21 
AnswerRe: Triggering a cellformatting event of a datagridview Pin
Maciej Los21-May-18 20:44
mveMaciej Los21-May-18 20:44 
Questioncoloring a cell via datagridview cellformatting event Pin
leone19-May-18 10:11
leone19-May-18 10:11 
AnswerRe: coloring a cell via datagridview cellformatting event Pin
Luc Pattyn19-May-18 12:04
sitebuilderLuc Pattyn19-May-18 12:04 
AnswerRe: coloring a cell via datagridview cellformatting event Pin
OriginalGriff19-May-18 19:55
mveOriginalGriff19-May-18 19:55 
AnswerRe: coloring a cell via datagridview cellformatting event Pin
leone24-May-18 11:13
leone24-May-18 11:13 
QuestionI want to read a value from a gridview cell using button event, something i'm not getting right here. Pin
Ngqulunga19-May-18 2:02
Ngqulunga19-May-18 2:02 
Questioni need to save me textbox data to separate line in notepad Pin
Mohamed Fahad M18-May-18 23:41
Mohamed Fahad M18-May-18 23:41 
AnswerRe: i need to save me textbox data to separate line in notepad Pin
OriginalGriff18-May-18 23:59
mveOriginalGriff18-May-18 23:59 
AnswerRe: i need to save me textbox data to separate line in notepad Pin
Dave Kreskowiak20-May-18 5:33
mveDave Kreskowiak20-May-18 5:33 
QuestionMy code is not calculating correctly... I just need an extra pair of eyes to help me see what I am missing. Please help Pin
Member 1383451318-May-18 21:59
Member 1383451318-May-18 21:59 
AnswerRe: My code is not calculating correctly... I just need an extra pair of eyes to help me see what I am missing. Please help Pin
OriginalGriff18-May-18 22:00
mveOriginalGriff18-May-18 22:00 
AnswerRe: My code is not calculating correctly... I just need an extra pair of eyes to help me see what I am missing. Please help Pin
Richard MacCutchan18-May-18 23:45
mveRichard MacCutchan18-May-18 23:45 
AnswerRe: My code is not calculating correctly... I just need an extra pair of eyes to help me see what I am missing. Please help Pin
Implements Master Yoda21-May-18 4:34
Implements Master Yoda21-May-18 4:34 
QuestionQuestion in principal regarding writing an Outlook Plugin Pin
Jim60718-May-18 0:35
Jim60718-May-18 0:35 

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.