Click here to Skip to main content
15,894,740 members
Home / Discussions / C#
   

C#

 
GeneralRe: How well do you know your TryParse()? Pin
Alan N14-Apr-12 12:56
Alan N14-Apr-12 12:56 
GeneralRe: How well do you know your TryParse()? Pin
Ravi Bhavnani14-Apr-12 13:00
professionalRavi Bhavnani14-Apr-12 13:00 
AnswerRe: How well do you know your TryParse()? Pin
Luc Pattyn14-Apr-12 13:40
sitebuilderLuc Pattyn14-Apr-12 13:40 
GeneralRe: How well do you know your TryParse()? Pin
Ravi Bhavnani14-Apr-12 13:51
professionalRavi Bhavnani14-Apr-12 13:51 
GeneralRe: How well do you know your TryParse()? Pin
PIEBALDconsult15-Apr-12 4:20
mvePIEBALDconsult15-Apr-12 4:20 
AnswerRe: How well do you know your TryParse()? Pin
PIEBALDconsult14-Apr-12 19:03
mvePIEBALDconsult14-Apr-12 19:03 
GeneralRe: How well do you know your TryParse()? Pin
Eddy Vluggen15-Apr-12 0:43
professionalEddy Vluggen15-Apr-12 0:43 
GeneralRe: How well do you know your TryParse()? Pin
DaveyM6915-Apr-12 0:56
professionalDaveyM6915-Apr-12 0:56 
Eddy Vluggen wrote:
it'll probably initialize it with the same value it initializes an empty variable


Double checked using Reflector...
C#
public static bool TryParse(string s, out decimal result)
{
    return Number.TryParseDecimal(s, NumberStyles.Number, NumberFormatInfo.CurrentInfo, out result);
}

C#
internal static unsafe bool TryParseDecimal(string value, NumberStyles options, NumberFormatInfo numfmt, out decimal result)
{
    byte* stackBuffer = stackalloc byte[0x72];
    NumberBuffer number = new NumberBuffer(stackBuffer);
    result = 0M; // result is set to zero here!
    if (!TryStringToNumber(value, options, ref number, numfmt, true))
    {
        return false;
    }
    if (!NumberBufferToDecimal(number.PackForNative(), ref result))
    {
        return false;
    }
    return true;
}

... so it WILL be zero.
Dave

Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.
Astonish us. Be exceptional. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)



GeneralRe: How well do you know your TryParse()? Pin
PIEBALDconsult15-Apr-12 4:22
mvePIEBALDconsult15-Apr-12 4:22 
GeneralRe: How well do you know your TryParse()? Pin
Ravi Bhavnani15-Apr-12 5:07
professionalRavi Bhavnani15-Apr-12 5:07 
AnswerRe: How well do you know your TryParse()? Pin
Luc Pattyn15-Apr-12 3:12
sitebuilderLuc Pattyn15-Apr-12 3:12 
GeneralRe: How well do you know your TryParse()? Pin
PIEBALDconsult15-Apr-12 4:08
mvePIEBALDconsult15-Apr-12 4:08 
GeneralRe: How well do you know your TryParse()? Pin
Luc Pattyn15-Apr-12 4:55
sitebuilderLuc Pattyn15-Apr-12 4:55 
GeneralRe: How well do you know your TryParse()? Pin
Ravi Bhavnani15-Apr-12 5:07
professionalRavi Bhavnani15-Apr-12 5:07 
GeneralRe: How well do you know your TryParse()? Pin
Ravi Bhavnani15-Apr-12 5:04
professionalRavi Bhavnani15-Apr-12 5:04 
AnswerRe: How well do you know your TryParse()? Pin
dybs16-Apr-12 11:06
dybs16-Apr-12 11:06 
GeneralRe: How well do you know your TryParse()? Pin
Ravi Bhavnani16-Apr-12 11:11
professionalRavi Bhavnani16-Apr-12 11:11 
QuestionHelp me C# Pin
h7h7h714-Apr-12 4:20
h7h7h714-Apr-12 4:20 
AnswerRe: Help me C# Pin
PIEBALDconsult14-Apr-12 4:40
mvePIEBALDconsult14-Apr-12 4:40 
AnswerRe: Help me C# Pin
Abhinav S14-Apr-12 5:23
Abhinav S14-Apr-12 5:23 
QuestionSnmp packet format Pin
Member 788151814-Apr-12 1:42
Member 788151814-Apr-12 1:42 
QuestionRe: Snmp packet format Pin
Eddy Vluggen15-Apr-12 0:44
professionalEddy Vluggen15-Apr-12 0:44 
AnswerRe: Snmp packet format Pin
Member 788151815-Apr-12 6:51
Member 788151815-Apr-12 6:51 
AnswerRe: Snmp packet format Pin
jschell16-Apr-12 12:26
jschell16-Apr-12 12:26 
AnswerRe: Snmp packet format Pin
Member 788151818-Apr-12 16:24
Member 788151818-Apr-12 16:24 

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.