Click here to Skip to main content
15,891,184 members
Home / Discussions / C#
   

C#

 
GeneralRe: Logic of prime numbers Pin
Member 113371082-Jan-15 14:19
Member 113371082-Jan-15 14:19 
GeneralRe: Logic of prime numbers Pin
SledgeHammer012-Jan-15 14:32
SledgeHammer012-Jan-15 14:32 
GeneralRe: Logic of prime numbers Pin
Member 113371082-Jan-15 15:06
Member 113371082-Jan-15 15:06 
GeneralRe: Logic of prime numbers Pin
SledgeHammer012-Jan-15 15:24
SledgeHammer012-Jan-15 15:24 
GeneralRe: Logic of prime numbers Pin
BillWoodruff3-Jan-15 11:59
professionalBillWoodruff3-Jan-15 11:59 
Questionhow can get number in a string in c# :(((((( Pin
mhd.sbt2-Jan-15 6:13
mhd.sbt2-Jan-15 6:13 
AnswerRe: how can get number in a string in c# :(((((( Pin
Pete O'Hanlon2-Jan-15 6:28
mvePete O'Hanlon2-Jan-15 6:28 
AnswerRe: how can get number in a string in c# :(((((( Pin
BillWoodruff2-Jan-15 7:43
professionalBillWoodruff2-Jan-15 7:43 
Great resource for RegEx's useful to convert from many formats to many numeric types: [^].

Try this:
C#
private string getID = @"'\d+'";

private Regex rxGetID;

private char[] trimQuote = new[] {'\''};

private int? htmlToInt(string match)
{
    rxGetID = new Regex(getID, RegexOptions.Compiled);

    string result = rxGetID.Match(match).Value.Trim(trimQuote);

    int intResult;

    return (Int32.TryParse(result, out intResult))
       ? intResult
       : (int?) null; // note the weird, but required, cast here
}

// test
private void Test()
{
    rxGetID = new Regex(getID,RegexOptions.Compiled);

    int? result = htmlToInt("<li> ID='45'");

    if (result != null)
    {
        // good to go
    }
    else
    {
        // throw error ?
    }
}      

«A man will be imprisoned in a room with a door that's unlocked and opens inwards ... as long as it does not occur to him to pull rather than push»  Wittgenstein

QuestionCan I write my own XBox 360 program? Pin
trantrum2-Jan-15 4:41
professionaltrantrum2-Jan-15 4:41 
AnswerRe: Can I write my own XBox 360 program? Pin
Richard MacCutchan2-Jan-15 4:53
mveRichard MacCutchan2-Jan-15 4:53 
AnswerRe: Can I write my own XBox 360 program? Pin
OriginalGriff2-Jan-15 5:00
mveOriginalGriff2-Jan-15 5:00 
GeneralRe: Can I write my own XBox 360 program? Pin
trantrum2-Jan-15 5:07
professionaltrantrum2-Jan-15 5:07 
GeneralRe: Can I write my own XBox 360 program? Pin
OriginalGriff2-Jan-15 5:13
mveOriginalGriff2-Jan-15 5:13 
GeneralRe: Can I write my own XBox 360 program? Pin
trantrum2-Jan-15 5:21
professionaltrantrum2-Jan-15 5:21 
GeneralRe: Can I write my own XBox 360 program? Pin
OriginalGriff2-Jan-15 5:25
mveOriginalGriff2-Jan-15 5:25 
AnswerRe: Can I write my own XBox 360 program? Pin
BillWoodruff2-Jan-15 6:56
professionalBillWoodruff2-Jan-15 6:56 
GeneralRe: Can I write my own XBox 360 program? Pin
trantrum2-Jan-15 9:20
professionaltrantrum2-Jan-15 9:20 
QuestionUnhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. - why? Pin
turbosupramk32-Jan-15 4:28
turbosupramk32-Jan-15 4:28 
AnswerRe: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. - why? Pin
Dave Kreskowiak2-Jan-15 4:35
mveDave Kreskowiak2-Jan-15 4:35 
GeneralRe: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. - why? Pin
turbosupramk32-Jan-15 5:07
turbosupramk32-Jan-15 5:07 
GeneralRe: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. - why? Pin
Dave Kreskowiak2-Jan-15 8:39
mveDave Kreskowiak2-Jan-15 8:39 
GeneralRe: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. - why? Pin
turbosupramk32-Jan-15 6:29
turbosupramk32-Jan-15 6:29 
GeneralRe: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. - why? Pin
Dave Kreskowiak2-Jan-15 8:38
mveDave Kreskowiak2-Jan-15 8:38 
GeneralRe: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. - why? Pin
turbosupramk32-Jan-15 8:46
turbosupramk32-Jan-15 8:46 
GeneralRe: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. - why? Pin
Dave Kreskowiak2-Jan-15 8:49
mveDave Kreskowiak2-Jan-15 8:49 

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.