Click here to Skip to main content
15,389,918 members
Home / Discussions / C#
   

C#

 
AnswerRe: Is there a way to improve this code? Pin
Pete O'Hanlon4-Jan-22 22:49
mvaPete O'Hanlon4-Jan-22 22:49 
QuestionCSV File Access - Error Msg : the process cannot access the file used by another process Pin
The Golden Man4-Jan-22 7:26
MemberThe Golden Man4-Jan-22 7:26 
AnswerRe: CSV File Access - Error Msg : the process cannot access the file used by another process Pin
Gerry Schmitz4-Jan-22 12:16
mveGerry Schmitz4-Jan-22 12:16 
QuestionAbout records Pin
Super Lloyd3-Jan-22 9:12
MemberSuper Lloyd3-Jan-22 9:12 
AnswerRe: About records Pin
OriginalGriff3-Jan-22 20:28
mveOriginalGriff3-Jan-22 20:28 
GeneralRe: About records Pin
Super Lloyd3-Jan-22 20:31
MemberSuper Lloyd3-Jan-22 20:31 
GeneralRe: About records Pin
Super Lloyd3-Jan-22 20:33
MemberSuper Lloyd3-Jan-22 20:33 
GeneralRe: About records Pin
Super Lloyd3-Jan-22 21:07
MemberSuper Lloyd3-Jan-22 21:07 
I guess they are quite handy to quickly create non trivial dictionary key...

for example:
C#
public static WeakDictionary<TKey, TValue> Get<TKey, TValue>()
    where TValue : class
    where TKey : notnull
{
    var k = new Key(typeof(TKey), typeof(TValue));
    if (!caches.TryGetValue(k, out var result))
    {
        lock (caches)
        {
            if (!caches.TryGetValue(k, out result))
            {
                result = new WeakDictionary<TKey, TValue>();
                caches[k] = result;
            }
        }
    }
    return (WeakDictionary<TKey, TValue>)result;
}

record class Key(Type key, Type value);
readonly static ConcurrentDictionary<Key, IWeakCache> caches = new();
A new .NET Serializer
All in one Menu-Ribbon Bar
Taking over the world since 1371!

GeneralRe: About records Pin
BillWoodruff4-Jan-22 4:49
mveBillWoodruff4-Jan-22 4:49 
AnswerRe: About records Pin
Richard Deeming3-Jan-22 23:14
mveRichard Deeming3-Jan-22 23:14 
GeneralRe: About records Pin
Super Lloyd3-Jan-22 23:17
MemberSuper Lloyd3-Jan-22 23:17 
AnswerRe: About records Pin
BillWoodruff4-Jan-22 5:38
mveBillWoodruff4-Jan-22 5:38 
GeneralRe: About records Pin
Super Lloyd4-Jan-22 5:49
MemberSuper Lloyd4-Jan-22 5:49 
AnswerRe: About records Pin
endo funk7-Jan-22 1:55
Memberendo funk7-Jan-22 1:55 
GeneralRe: About records Pin
Super Lloyd7-Jan-22 8:49
MemberSuper Lloyd7-Jan-22 8:49 
GeneralRe: About records Pin
endo funk7-Jan-22 10:39
Memberendo funk7-Jan-22 10:39 
QuestionBlazor: IEnumerable ElementAt Pin
chrisb15162-Jan-22 23:49
Memberchrisb15162-Jan-22 23:49 
AnswerRe: Blazor: IEnumerable ElementAt Pin
#realJSOP3-Jan-22 2:16
mva#realJSOP3-Jan-22 2:16 
GeneralRe: Blazor: IEnumerable ElementAt Pin
chrisb15163-Jan-22 10:11
Memberchrisb15163-Jan-22 10:11 
GeneralRe: Blazor: IEnumerable ElementAt Pin
#realJSOP3-Jan-22 22:39
mva#realJSOP3-Jan-22 22:39 
AnswerRe: Blazor: IEnumerable ElementAt Pin
OriginalGriff3-Jan-22 2:23
mveOriginalGriff3-Jan-22 2:23 
AnswerRe: Blazor: IEnumerable ElementAt Pin
Gerry Schmitz3-Jan-22 5:51
mveGerry Schmitz3-Jan-22 5:51 
GeneralRe: Blazor: IEnumerable ElementAt Pin
OriginalGriff3-Jan-22 6:28
mveOriginalGriff3-Jan-22 6:28 
Questioncausing the computer to freeze Pin
Calin Cali2-Jan-22 4:01
MemberCalin Cali2-Jan-22 4:01 
AnswerRe: causing the computer to freeze Pin
Gerry Schmitz2-Jan-22 4:42
mveGerry Schmitz2-Jan-22 4:42 

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.