Click here to Skip to main content
14,606,461 members
   

C#

 
GeneralRe: continuous PING application ? Pin
auting8211-Feb-20 10:48
Memberauting8211-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
MemberBice908-Feb-20 1:07 
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
MemberBice908-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 
I agree with Richard: have an array.
It might be worth doing it this way:

Create a class to hold the value and it's associated label. You can then create an array or other collection of class instances, and just loop through them, doing the same code once.
To help with that, override the ToString method in the class, and have it return the "human readable" value:
public class DisplayValue
    {
    public double Value { get; set; }
    public Label Label { get; set; }
    public override string ToString()
        {
        return Value < 1.0 ? (1000 * value).ToString("0.###") + " mV"
                           : Value.ToString("0.###") + " V";
        }
    }
That way, it can be rather more flexible than just setting a label value.
foreach (DisplayValue dv in Values)
   {
   dv.Label.Text = dv.ToString();
   }

"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!

GeneralRe: Modifying multiple fields based on a condition Pin
Bice908-Feb-20 4:12
MemberBice908-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
MemberBice908-Feb-20 4:15 
AnswerRe: Modifying multiple fields based on a condition Pin
phil.o8-Feb-20 3:04
mvephil.o8-Feb-20 3:04 
GeneralRe: Modifying multiple fields based on a condition Pin
Bice908-Feb-20 4:17
MemberBice908-Feb-20 4:17 
GeneralRe: Modifying multiple fields based on a condition Pin
phil.o8-Feb-20 4:53
mvephil.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
MemberBice908-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
MemberBice908-Feb-20 6:22 
QuestionC# Interviews on the horizon Pin
Andrew Torrance7-Feb-20 3:11
MemberAndrew Torrance7-Feb-20 3:11 
AnswerRe: C# Interviews on the horizon Pin
OriginalGriff7-Feb-20 3:52
mveOriginalGriff7-Feb-20 3:52 
GeneralRe: C# Interviews on the horizon Pin
Andrew Torrance7-Feb-20 6:51
MemberAndrew Torrance7-Feb-20 6:51 
GeneralRe: C# Interviews on the horizon Pin
phil.o7-Feb-20 23:05
mvephil.o7-Feb-20 23:05 
QuestionPerformance penalty of Debug.Assert in .NET Pin
Rob Philpott4-Feb-20 23:44
MemberRob Philpott4-Feb-20 23:44 
AnswerRe: Performance penalty of Debug.Assert in .NET Pin
OriginalGriff4-Feb-20 23:57
mveOriginalGriff4-Feb-20 23:57 
AnswerRe: Performance penalty of Debug.Assert in .NET Pin
OriginalGriff5-Feb-20 0:17
mveOriginalGriff5-Feb-20 0:17 

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.