Click here to Skip to main content
15,606,568 members
Home / Discussions / C#
   

C#

 
AnswerRe: re-create a local database Pin
OriginalGriff15-Dec-21 20:54
mvaOriginalGriff15-Dec-21 20:54 
AnswerRe: re-create a local database Pin
#realJSOP16-Dec-21 2:39
mva#realJSOP16-Dec-21 2:39 
GeneralRe: re-create a local database Pin
jschell23-Dec-21 5:50
jschell23-Dec-21 5:50 
QuestionHow do i gate the previous values in Crystal repor Pin
remiki14-Dec-21 7:37
remiki14-Dec-21 7:37 
AnswerRe: How do i gate the previous values in Crystal repor Pin
remiki16-Dec-21 0:56
remiki16-Dec-21 0:56 
QuestionParse from string Pin
Member 1546737514-Dec-21 4:00
Member 1546737514-Dec-21 4:00 
AnswerRe: Parse from string Pin
Pete O'Hanlon14-Dec-21 5:21
subeditorPete O'Hanlon14-Dec-21 5:21 
GeneralRe: Parse from string Pin
jsc4214-Dec-21 6:55
professionaljsc4214-Dec-21 6:55 
Point.Parse does not seem to cater for the fact that the OP has 'swapped' commas and periods in his/her locale. Nor is it clear if the '(' and ')' are mandatory / banned / optional. The best that I have come up with is ...

C#
public static bool TryParse(string s, out Point p)
{
    int x = 0;  // Temp values to hold x and y coordinates of the parsed Point
    int y = 0;

    // String can optionally be surrounded by '(' and ')' and values can be separated by ',' or '.' e.g.
    //  (x,y)
    //  x,y
    //  (x.y)
    //  x.y
    string unparenthesisedValue =
        s.StartsWith("(") && s.EndsWith(")")
        ? s.Substring(1, s.Length - 2)  // Strip off '(' and ')'
        : s;    // No parentheses

    string[] parts = unparenthesisedValue.Split(',');   // Look for x,y
    if (parts.Length != 2)  // Not x,y
        parts = unparenthesisedValue.Split('.');    // Look for x.y

    //Console.Write($"s = {s}, Len = {parts.Length}, Parts = [{ String.Join(", ", parts)}]");

    bool validPoint =
        parts.Length == 2   // Two numbers
        && int.TryParse(parts[0], out x)    // First number looks OK
        && int.TryParse(parts[1], out y);   // Second number looks OK

    p = new Point(x, y);
    return validPoint;
}

This will parse with '(' and ')' as optional (both or neither; but not just one of the pair; either ',' or '.' as separator; any spaces either side of the numbers. If you have more than one '.' or ',' it gets rejected as there are either too many components of you have floating point nos.
AnswerRe: Parse from string Pin
#realJSOP15-Dec-21 0:35
mva#realJSOP15-Dec-21 0:35 
GeneralRe: Parse from string Pin
jsc4215-Dec-21 0:49
professionaljsc4215-Dec-21 0:49 
GeneralRe: Parse from string Pin
#realJSOP15-Dec-21 6:54
mva#realJSOP15-Dec-21 6:54 
Questionc# Search in root/subtree active directory users Pin
jwradhe9-Dec-21 2:10
jwradhe9-Dec-21 2:10 
AnswerRe: c# Search in root/subtree active directory users Pin
Richard Andrew x6411-Dec-21 9:16
professionalRichard Andrew x6411-Dec-21 9:16 
QuestionAccess Exif Metadata Pin
Dave Dec20216-Dec-21 10:05
Dave Dec20216-Dec-21 10:05 
AnswerRe: Access Exif Metadata Pin
OriginalGriff6-Dec-21 10:19
mvaOriginalGriff6-Dec-21 10:19 
GeneralRe: Access Exif Metadata Pin
Dave Dec20216-Dec-21 13:09
Dave Dec20216-Dec-21 13:09 
GeneralRe: Access Exif Metadata Pin
Luc Pattyn6-Dec-21 16:39
sitebuilderLuc Pattyn6-Dec-21 16:39 
GeneralRe: Access Exif Metadata Pin
Dave Dec20216-Dec-21 21:24
Dave Dec20216-Dec-21 21:24 
GeneralRe: Access Exif Metadata Pin
Dave Dec20217-Dec-21 17:02
Dave Dec20217-Dec-21 17:02 
GeneralRe: Access Exif Metadata Pin
Luc Pattyn7-Dec-21 17:20
sitebuilderLuc Pattyn7-Dec-21 17:20 
GeneralRe: Access Exif Metadata Pin
Dave Dec20217-Dec-21 20:51
Dave Dec20217-Dec-21 20:51 
GeneralRe: Access Exif Metadata Pin
Richard MacCutchan7-Dec-21 22:13
mveRichard MacCutchan7-Dec-21 22:13 
GeneralRe: Access Exif Metadata Pin
Richard Deeming7-Dec-21 22:17
mveRichard Deeming7-Dec-21 22:17 
QuestionCreated Access DB, now how to load a list into a single column in the newly created DB. Pin
Richard A Knox4-Dec-21 6:18
Richard A Knox4-Dec-21 6:18 
AnswerRe: Created Access DB, now how to load a list into a single column in the newly created DB. Pin
OriginalGriff4-Dec-21 6:48
mvaOriginalGriff4-Dec-21 6:48 

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.