© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
9 replies
SWEETPONY

❔ How to correctly write this linq query?

I have following code:
private string FormatLocalDateLong(LocalDate localDate)
    => localDate
          .ToString( "dd.MM.yyyy", _ruCulture );
private string FormatLocalDateLong(LocalDate localDate)
    => localDate
          .ToString( "dd.MM.yyyy", _ruCulture );


I decided to extand function and did this:
private string FormatLocalDateLong( LocalDate localDate )
   => localDate
        .ToString( "dd.MM.yyyy", _ruCulture )
        .FormatResolvedValues();

public static string FormatResolvedValues( this string localDate )
        => localDate.EndsWith( "9999" )
            ? "/"
            : localDate;  
private string FormatLocalDateLong( LocalDate localDate )
   => localDate
        .ToString( "dd.MM.yyyy", _ruCulture )
        .FormatResolvedValues();

public static string FormatResolvedValues( this string localDate )
        => localDate.EndsWith( "9999" )
            ? "/"
            : localDate;  


All I want is to write the same without extansion
FormatResolvedValues
FormatResolvedValues

Smth like that but I don't understand how to write it correctly:
private string FormatLocalDateLong( LocalDate localDate )
   => localDate
        .ToString( "dd.MM.yyyy", _ruCulture )
        .EndsWith("9999")
             ? "/"
             : ... (I don't want to write .ToString() again);
private string FormatLocalDateLong( LocalDate localDate )
   => localDate
        .ToString( "dd.MM.yyyy", _ruCulture )
        .EndsWith("9999")
             ? "/"
             : ... (I don't want to write .ToString() again);
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ LINQ, simple query
C#CC# / help
2y ago
❔ Linq Query HELP
C#CC# / help
3y ago
✅ How to correctly write conditions with expressions?
C#CC# / help
2y ago
How to do this with LINQ?
C#CC# / help
3y ago