Click here to Skip to main content
14,773,124 members
Home » Discussions » C#
   

C#

 
AnswerRe: How to make connection with SQL Server on another computer? Pin
DerekT-P17-Dec-20 11:16
professionalDerekT-P17-Dec-20 11:16 
QuestionComboBoxItem in another Form Pin
AnissGharib4917-Dec-20 3:09
MemberAnissGharib4917-Dec-20 3:09 
AnswerRe: ComboBoxItem in another Form Pin
Dave Kreskowiak17-Dec-20 4:56
mveDave Kreskowiak17-Dec-20 4:56 
AnswerRe: ComboBoxItem in another Form Pin
OriginalGriff17-Dec-20 5:40
mveOriginalGriff17-Dec-20 5:40 
AnswerRe: ComboBoxItem in another Form Pin
Gerry Schmitz17-Dec-20 5:48
mveGerry Schmitz17-Dec-20 5:48 
AnswerRe: ComboBoxItem in another Form Pin
Herboren18-Dec-20 11:55
MemberHerboren18-Dec-20 11:55 
QuestionBecoming functional: adding Option of T to List when IsSome only Pin
Bernhard Hiller13-Dec-20 23:55
MemberBernhard Hiller13-Dec-20 23:55 
AnswerRe: Becoming functional: adding Option of T to List when IsSome only Pin
Richard Deeming14-Dec-20 1:41
mveRichard Deeming14-Dec-20 1:41 
If you didn't want to log the failures, it could be as simple as:
m_Geometry.TryGetAnglesForPosition(intersectionPoint, _name).IfSome(result.Add);
Otherwise, something like this should work:
m_Geometry.TryGetAnglesForPosition(intersectionPoint, _name).Match(
    point => result.Add(point),
    () => Logger.LogWarning(Name, $"Cannot determine angle for position '{intersectionPoint}' corresponding to pixel '{pixel}'."));
There's also the C# 8 property patterns:
if (m_Geometry.TryGetAnglesForPosition(intersectionPoint, _name) is { IsSome: true } angle)
{
    angle.IfSome(result.Add);
}
else
{
    Logger.LogWarning(Name, $"Cannot determine angle for position '{intersectionPoint}' corresponding to pixel '{pixel}'.");
}
Or you could define a deconstructor as an extension method:
public static class OptionTExtensions
{
    public static void Deconstruct<T>(this Option<T> option, bool isSome, T value)
    {
        isSome = option.IsSome;
        value = isSome ? (T)option : default;
    }
}
...
var (isSome, point) = m_Geometry.TryGetAnglesForPosition(intersectionPoint, _name);
if (isSome)
{
    result.Add(point);
}
else
{
    Logger.LogWarning(Name, $"Cannot determine angle for position '{intersectionPoint}' corresponding to pixel '{pixel}'.");
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: Becoming functional: adding Option of T to List when IsSome only Pin
Bernhard Hiller14-Dec-20 3:40
MemberBernhard Hiller14-Dec-20 3:40 
Questionc# programing Pin
toori shabab9-Dec-20 4:50
Membertoori shabab9-Dec-20 4:50 
AnswerRe: c# programing Pin
Richard Deeming9-Dec-20 4:53
mveRichard Deeming9-Dec-20 4:53 
AnswerRe: c# programing Pin
OriginalGriff9-Dec-20 5:28
mveOriginalGriff9-Dec-20 5:28 
JokeRe: c# programing Pin
CHill609-Dec-20 6:11
mveCHill609-Dec-20 6:11 
GeneralRe: c# programing Pin
OriginalGriff9-Dec-20 6:20
mveOriginalGriff9-Dec-20 6:20 
GeneralRe: c# programing Pin
CHill609-Dec-20 7:00
mveCHill609-Dec-20 7:00 
AnswerRe: c# programing Pin
Gerry Schmitz9-Dec-20 6:48
mveGerry Schmitz9-Dec-20 6:48 
AnswerRe: c# programing Pin
Pete O'Hanlon9-Dec-20 22:52
mvePete O'Hanlon9-Dec-20 22:52 
QuestionSend GMail Pin
Kevin Marois7-Dec-20 17:41
professionalKevin Marois7-Dec-20 17:41 
AnswerRe: Send GMail Pin
OriginalGriff7-Dec-20 22:04
mveOriginalGriff7-Dec-20 22:04 
AnswerRe: Send GMail Pin
Richard Deeming7-Dec-20 22:55
mveRichard Deeming7-Dec-20 22:55 
Questionc# language issue: when you need to serialize/deserialize a user defined Func/Action Pin
BillWoodruff7-Dec-20 3:40
mveBillWoodruff7-Dec-20 3:40 
QuestionPlatform dependency of thread management Pin
Bernhard Hiller7-Dec-20 0:30
MemberBernhard Hiller7-Dec-20 0:30 
AnswerRe: Platform dependency of thread management Pin
Dave Kreskowiak7-Dec-20 4:59
mveDave Kreskowiak7-Dec-20 4:59 
QuestionC# NET. Framework program (area 2x) Pin
Member 150126776-Dec-20 0:49
MemberMember 150126776-Dec-20 0:49 
AnswerRe: C# NET. Framework program (area 2x) Pin
Richard MacCutchan6-Dec-20 2:28
mveRichard MacCutchan6-Dec-20 2:28 

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.