Click here to Skip to main content
15,886,963 members
Home / Discussions / C#
   

C#

 
GeneralRe: Windows Media Player - Play MP3. Pin
Afzaal Ahmad Zeeshan21-Nov-16 1:23
professionalAfzaal Ahmad Zeeshan21-Nov-16 1:23 
AnswerRe: Windows Media Player - Play MP3. Pin
RichardGrimmer21-Nov-16 4:42
RichardGrimmer21-Nov-16 4:42 
QuestionNetwork File Path Problem Pin
Kevin Marois18-Nov-16 10:30
professionalKevin Marois18-Nov-16 10:30 
AnswerRe: Network File Path Problem Pin
OriginalGriff18-Nov-16 21:44
mveOriginalGriff18-Nov-16 21:44 
AnswerRe: Network File Path Problem Pin
Bernhard Hiller20-Nov-16 21:10
Bernhard Hiller20-Nov-16 21:10 
AnswerRe: Network File Path Problem Pin
Richard Deeming21-Nov-16 2:58
mveRichard Deeming21-Nov-16 2:58 
GeneralRe: Network File Path Problem Pin
Kevin Marois21-Nov-16 4:43
professionalKevin Marois21-Nov-16 4:43 
QuestionHow To Refactor This Pin
Kevin Marois18-Nov-16 4:48
professionalKevin Marois18-Nov-16 4:48 
I've got this chuck of code. It looks for different phrases in a line of text being read from a file, then extracts the data at the end and stores it to various properties. The data will be either an IN RANGE or OUT OF RANGE message:

"Denature 1 RTD in range. Reading: 9.64241027832031"

or

"Detection 2 RTD out of range. Reading: 510"

I have 5 different properties that need to be set from the data. I would like to make this into a method call but how would you pass in the property?

The first word of the line determines which property to be set.
var index = line.IndexOf("Denature 1 RTD in range. Reading:");
if (index > -1)
{
    var data = line.Substring(index + 33);
    ((RTDTestModel)model).Denature1ActualValue = Convert.ToDouble(data);
}

index = line.IndexOf("Denature 1 RTD out of range. Reading:");
if (index > -1)
{
    var data = line.Substring(index + 37);
    ((RTDTestModel)model).Denature1ActualValue = Convert.ToDouble(data);
}
index = line.IndexOf("Extension 2 RTD in range. Reading:");
if (index > -1)
{
    var data = line.Substring(index + 34);
    ((RTDTestModel)model).Extension2ActualValue = Convert.ToDouble(data);
}
index = line.IndexOf("Extension 2 RTD out range. Reading:");
if (index > -1)
{
    var data = line.Substring(index + 38);
    ((RTDTestModel)model).Extension2ActualValue = Convert.ToDouble(data);
}

Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

AnswerRe: How To Refactor This Pin
Pete O'Hanlon18-Nov-16 5:41
mvePete O'Hanlon18-Nov-16 5:41 
GeneralRe: How To Refactor This Pin
Kevin Marois18-Nov-16 6:03
professionalKevin Marois18-Nov-16 6:03 
GeneralRe: How To Refactor This Pin
Gerry Schmitz18-Nov-16 7:49
mveGerry Schmitz18-Nov-16 7:49 
GeneralRe: How To Refactor This Pin
Kevin Marois18-Nov-16 9:03
professionalKevin Marois18-Nov-16 9:03 
GeneralRe: How To Refactor This Pin
Gerry Schmitz18-Nov-16 10:44
mveGerry Schmitz18-Nov-16 10:44 
QuestionSaving Datagridview Pin
Member 1285691017-Nov-16 12:23
Member 1285691017-Nov-16 12:23 
AnswerRe: Saving Datagridview Pin
Dave Kreskowiak17-Nov-16 13:00
mveDave Kreskowiak17-Nov-16 13:00 
QuestionWinForm Installation Config files directory .. Pin
JP9017-Nov-16 6:05
JP9017-Nov-16 6:05 
AnswerRe: WinForm Installation Config files directory .. Pin
OriginalGriff17-Nov-16 6:38
mveOriginalGriff17-Nov-16 6:38 
Questionenquary Pin
Ramesh_sahu16-Nov-16 22:22
Ramesh_sahu16-Nov-16 22:22 
AnswerRe: enquary PinPopular
Richard MacCutchan16-Nov-16 22:27
mveRichard MacCutchan16-Nov-16 22:27 
GeneralRe: enquary Pin
Pete O'Hanlon16-Nov-16 22:55
mvePete O'Hanlon16-Nov-16 22:55 
GeneralRe: enquary Pin
Richard MacCutchan16-Nov-16 23:23
mveRichard MacCutchan16-Nov-16 23:23 
AnswerRe: enquary Pin
Pete O'Hanlon16-Nov-16 23:01
mvePete O'Hanlon16-Nov-16 23:01 
GeneralRe: enquary Pin
Mycroft Holmes16-Nov-16 23:05
professionalMycroft Holmes16-Nov-16 23:05 
GeneralRe: enquary Pin
OriginalGriff16-Nov-16 23:11
mveOriginalGriff16-Nov-16 23:11 
GeneralRe: enquary Pin
Pete O'Hanlon17-Nov-16 0:42
mvePete O'Hanlon17-Nov-16 0:42 

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.