Click here to Skip to main content
15,895,656 members
Home / Discussions / C#
   

C#

 
QuestionDisplaying data in a textBox Pin
Luis M. Rojas16-Dec-21 8:50
Luis M. Rojas16-Dec-21 8:50 
AnswerRe: Displaying data in a textBox Pin
trønderen16-Dec-21 9:10
trønderen16-Dec-21 9:10 
AnswerRe: Displaying data in a textBox Pin
OriginalGriff16-Dec-21 9:50
mveOriginalGriff16-Dec-21 9:50 
GeneralRe: Displaying data in a textBox Pin
Eddy Vluggen17-Dec-21 1:14
professionalEddy Vluggen17-Dec-21 1:14 
GeneralRe: Displaying data in a textBox Pin
OriginalGriff17-Dec-21 1:42
mveOriginalGriff17-Dec-21 1:42 
GeneralRe: Displaying data in a textBox Pin
Eddy Vluggen17-Dec-21 2:58
professionalEddy Vluggen17-Dec-21 2:58 
QuestionMonthCalendar - Adding a date without having the month or year. Pin
Richard A Knox16-Dec-21 3:06
Richard A Knox16-Dec-21 3:06 
AnswerRe: MonthCalendar - Adding a date without having the month or year. Pin
PIEBALDconsult16-Dec-21 3:07
mvePIEBALDconsult16-Dec-21 3:07 
AnswerRe: MonthCalendar - Adding a date without having the month or year. Pin
OriginalGriff16-Dec-21 4:09
mveOriginalGriff16-Dec-21 4:09 
AnswerRe: MonthCalendar - Adding a date without having the month or year. Pin
#realJSOP17-Dec-21 2:40
mve#realJSOP17-Dec-21 2:40 
Questionre-create a local database Pin
steven_noppe15-Dec-21 20:04
steven_noppe15-Dec-21 20:04 
AnswerRe: re-create a local database Pin
OriginalGriff15-Dec-21 20:54
mveOriginalGriff15-Dec-21 20:54 
AnswerRe: re-create a local database Pin
#realJSOP16-Dec-21 2:39
mve#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
mvePete 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
mve#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
mve#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 

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.