Click here to Skip to main content
15,791,440 members
Home / Discussions / C#
   

C#

 
AnswerRe: Proper Error handling Pin
Gerry Schmitz3-Sep-20 17:30
mveGerry Schmitz3-Sep-20 17:30 
GeneralRe: Proper Error handling Pin
Exoskeletor3-Sep-20 18:48
Exoskeletor3-Sep-20 18:48 
AnswerRe: Proper Error handling Pin
GuyThiebaut4-Sep-20 4:08
professionalGuyThiebaut4-Sep-20 4:08 
GeneralRe: Proper Error handling Pin
Exoskeletor4-Sep-20 4:23
Exoskeletor4-Sep-20 4:23 
QuestionCsvHelper, converting $0.00 to 0.00 Pin
jkirkerx3-Sep-20 13:08
professionaljkirkerx3-Sep-20 13:08 
AnswerRe: CsvHelper, converting $0.00 to 0.00 Pin
Gerry Schmitz3-Sep-20 13:55
mveGerry Schmitz3-Sep-20 13:55 
GeneralRe: CsvHelper, converting $0.00 to 0.00 Pin
jkirkerx3-Sep-20 14:20
professionaljkirkerx3-Sep-20 14:20 
AnswerGot It Pin
jkirkerx4-Sep-20 7:34
professionaljkirkerx4-Sep-20 7:34 
Wrote a TypeConverter, Took me awhile to understand how it works
I tried modifying the input text, with replace, but was not able to change it's value.
So I went with TryParse to generate a new double to send back, and just used substring to chop the $ off.
I bet the 2nd parse will fail now that I think about it. it should be TryParse as well.
public class PriceConverter<T> : DefaultTypeConverter
{
    public override object ConvertFromString(string text, IReaderRow row, MemberMapData memberMapData)
    {
        var result = 0.00;
        if (text.StartsWith("$"))
        {
            double.TryParse(text.Substring(1, text.Length - 1), out result);<br />
        }
        else
        {
            result = double.Parse(text);
        }

        return result;              
    }        
}
And the map
Map(m => m.SoldFor).Index(25).TypeConverter<PriceConverter<double>>();

Hope this helps somebody in the future
If it ain't broke don't fix it
Discover my world at jkirkerx.com


modified 4-Sep-20 12:40pm.

GeneralRe: Got It Pin
Mycroft Holmes4-Sep-20 13:15
professionalMycroft Holmes4-Sep-20 13:15 
GeneralRe: Got It Pin
jkirkerx4-Sep-20 14:54
professionaljkirkerx4-Sep-20 14:54 
AnswerI have 3 or 5 of them now, yes they need more work Pin
jkirkerx4-Sep-20 15:08
professionaljkirkerx4-Sep-20 15:08 
GeneralRe: I have 3 or 5 of them now, yes they need more work Pin
Gerry Schmitz5-Sep-20 4:58
mveGerry Schmitz5-Sep-20 4:58 
GeneralRe: I have 3 or 5 of them now, yes they need more work Pin
jkirkerx5-Sep-20 8:24
professionaljkirkerx5-Sep-20 8:24 
QuestionCsvHelper, EBay Order Csv file, not sure how to handle header with quotes and first line of commas Pin
jkirkerx2-Sep-20 14:55
professionaljkirkerx2-Sep-20 14:55 
AnswerRe: CsvHelper, EBay Order Csv file, not sure how to handle header with quotes and first line of commas Pin
OriginalGriff2-Sep-20 23:42
mvaOriginalGriff2-Sep-20 23:42 
GeneralRe: CsvHelper, EBay Order Csv file, not sure how to handle header with quotes and first line of commas Pin
jkirkerx3-Sep-20 7:11
professionaljkirkerx3-Sep-20 7:11 
GeneralRe: CsvHelper, EBay Order Csv file, not sure how to handle header with quotes and first line of commas Pin
Dave Kreskowiak3-Sep-20 9:51
mveDave Kreskowiak3-Sep-20 9:51 
AnswerRe: CsvHelper, EBay Order Csv file, not sure how to handle header with quotes and first line of commas PinPopular
Richard Deeming2-Sep-20 23:50
mveRichard Deeming2-Sep-20 23:50 
GeneralRe: CsvHelper, EBay Order Csv file, not sure how to handle header with quotes and first line of commas Pin
jkirkerx3-Sep-20 7:13
professionaljkirkerx3-Sep-20 7:13 
AnswerRe: CsvHelper, EBay Order Csv file, not sure how to handle header with quotes and first line of commas Pin
Luc Pattyn3-Sep-20 2:36
sitebuilderLuc Pattyn3-Sep-20 2:36 
GeneralRe: CsvHelper, EBay Order Csv file, not sure how to handle header with quotes and first line of commas Pin
jkirkerx3-Sep-20 7:12
professionaljkirkerx3-Sep-20 7:12 
AnswerRe: CsvHelper, EBay Order Csv file, not sure how to handle header with quotes and first line of commas Pin
jkirkerx3-Sep-20 7:31
professionaljkirkerx3-Sep-20 7:31 
AnswerRe: CsvHelper, EBay Order Csv file, not sure how to handle header with quotes and first line of commas Pin
Gerry Schmitz3-Sep-20 11:23
mveGerry Schmitz3-Sep-20 11:23 
QuestionConnect POST server call with HttpListener C# Pin
jdamiancabello2-Sep-20 1:21
jdamiancabello2-Sep-20 1:21 
AnswerRe: Connect POST server call with HttpListener C# Pin
Afzaal Ahmad Zeeshan3-Sep-20 6:19
professionalAfzaal Ahmad Zeeshan3-Sep-20 6:19 

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.