Click here to Skip to main content
15,887,888 members
Home / Discussions / C#
   

C#

 
QuestionHow to Pass the textbox value into Textbox1 in Web Browser in WPF Pin
Hernany Bondoc11-Feb-20 6:27
Hernany Bondoc11-Feb-20 6:27 
Questioncontinuous PING application ? Pin
auting8210-Feb-20 9:27
auting8210-Feb-20 9:27 
AnswerRe: continuous PING application ? Pin
k505410-Feb-20 10:48
mvek505410-Feb-20 10:48 
GeneralRe: continuous PING application ? Pin
auting8211-Feb-20 9:31
auting8211-Feb-20 9:31 
GeneralRe: continuous PING application ? Pin
k505411-Feb-20 10:27
mvek505411-Feb-20 10:27 
GeneralRe: continuous PING application ? Pin
auting8211-Feb-20 10:48
auting8211-Feb-20 10:48 
AnswerRe: continuous PING application ? Pin
Gerry Schmitz10-Feb-20 13:56
mveGerry Schmitz10-Feb-20 13:56 
QuestionModifying multiple fields based on a condition Pin
Bice908-Feb-20 1:07
Bice908-Feb-20 1:07 
Hi!

I have a question regarding the topic I mentioned in the subject.

I am trying to process numbers (voltage values) and print them nicely on the user interface of my software. What I do now is that I manually code everything. I have 8 different values and I do the following:
C#
Label1.Text = value1.ToString("0.###") + " V";
Label2.Text = value2.ToString("0.###") + " V";
.
.
.
Label8.Text = value8.ToString("0.###") + " V";
"

It works, and everything, but I wonder if there is an elegant solution which runs through the labels and the variables at the same time? And also, is it faster in the more elegant way?

And I have another question related to the code above. Let's say, these values are smaller than 1. In that case, it would be nicer to print the voltage in milivolts, so we see the digits in a more convenient way. For that, my idea would be a simple if-else statement:
C#
if(value1<1.0)
{
Label1.Text = (1000*value1).ToString("0.###") + " mV";
//note: we only have positive values. Otherwise, for example '-1.2V' would be shown wrong...
}
else
{
Label1.Text = value1.ToString("0.###") + " V";
}

But, the problem is similar as the first part of the problem. Should I go through each of these cases manually by writing 8 if-else statements for each values, or there is a better (faster), more elegant way?

My code is starting to have a lot of if-else statements because of similar things (for example, checking the state of check boxes) and I start to think whether it has a negative impact on the performance or not?

Thank you very much for your input!
AnswerRe: Modifying multiple fields based on a condition Pin
Richard MacCutchan8-Feb-20 1:41
mveRichard MacCutchan8-Feb-20 1:41 
GeneralRe: Modifying multiple fields based on a condition Pin
Bice908-Feb-20 4:10
Bice908-Feb-20 4:10 
GeneralRe: Modifying multiple fields based on a condition Pin
jsc4210-Feb-20 4:09
professionaljsc4210-Feb-20 4:09 
GeneralRe: Modifying multiple fields based on a condition Pin
Richard MacCutchan10-Feb-20 5:11
mveRichard MacCutchan10-Feb-20 5:11 
AnswerRe: Modifying multiple fields based on a condition Pin
OriginalGriff8-Feb-20 2:49
mveOriginalGriff8-Feb-20 2:49 
GeneralRe: Modifying multiple fields based on a condition Pin
Bice908-Feb-20 4:12
Bice908-Feb-20 4:12 
AnswerRe: Modifying multiple fields based on a condition Pin
Eddy Vluggen8-Feb-20 2:51
professionalEddy Vluggen8-Feb-20 2:51 
GeneralRe: Modifying multiple fields based on a condition Pin
Bice908-Feb-20 4:15
Bice908-Feb-20 4:15 
AnswerRe: Modifying multiple fields based on a condition Pin
phil.o8-Feb-20 3:04
professionalphil.o8-Feb-20 3:04 
GeneralRe: Modifying multiple fields based on a condition Pin
Bice908-Feb-20 4:17
Bice908-Feb-20 4:17 
GeneralRe: Modifying multiple fields based on a condition Pin
phil.o8-Feb-20 4:53
professionalphil.o8-Feb-20 4:53 
AnswerRe: Modifying multiple fields based on a condition Pin
Gerry Schmitz8-Feb-20 3:41
mveGerry Schmitz8-Feb-20 3:41 
GeneralRe: Modifying multiple fields based on a condition Pin
Bice908-Feb-20 4:25
Bice908-Feb-20 4:25 
GeneralRe: Modifying multiple fields based on a condition Pin
Gerry Schmitz8-Feb-20 4:52
mveGerry Schmitz8-Feb-20 4:52 
GeneralRe: Modifying multiple fields based on a condition Pin
Bice908-Feb-20 6:22
Bice908-Feb-20 6:22 
QuestionC# Interviews on the horizon Pin
Andrew Torrance7-Feb-20 3:11
Andrew Torrance7-Feb-20 3:11 
AnswerRe: C# Interviews on the horizon Pin
OriginalGriff7-Feb-20 3:52
mveOriginalGriff7-Feb-20 3:52 

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.