Click here to Skip to main content
16,012,061 members
Home / Discussions / C#
   

C#

 
PinnedHOW TO ANSWER A QUESTION PinPopular
Chris Maunder12-Jul-09 22:36
cofounderChris Maunder12-Jul-09 22:36 
PinnedHow to get an answer to your question Pin
Chris Maunder10-Nov-05 16:31
cofounderChris Maunder10-Nov-05 16:31 
QuestionHow to use functions of a dll in another dll "on the fly" Pin
AtaChris28-Sep-24 1:56
AtaChris28-Sep-24 1:56 
AnswerRe: How to use functions of a dll in another dll "on the fly" Pin
Richard MacCutchan28-Sep-24 3:21
mveRichard MacCutchan28-Sep-24 3:21 
GeneralRe: How to use functions of a dll in another dll "on the fly" Pin
AtaChris28-Sep-24 3:40
AtaChris28-Sep-24 3:40 
GeneralRe: How to use functions of a dll in another dll "on the fly" Pin
Richard MacCutchan28-Sep-24 3:42
mveRichard MacCutchan28-Sep-24 3:42 
AnswerRe: How to use functions of a dll in another dll "on the fly" Pin
Luc Pattyn23hrs 35mins ago
sitebuilderLuc Pattyn23hrs 35mins ago 
AnswerRe: How to use functions of a dll in another dll "on the fly" Pin
jschell12mins ago
jschell12mins ago 
QuestionInterface with a default implementation Pin
Richard Andrew x6427-Sep-24 17:42
professionalRichard Andrew x6427-Sep-24 17:42 
I'm having trouble getting my mind around how a default method in an interface works.
Picture the below interface and default method implementation:
C#
    public interface IClientForm
    {
        delegate void WindowClosedDelegate(object sender, WindowEventArgs args);
        event WindowClosedDelegate OnClosed;

        long FormId { get; set; }

        UIContextClass UIContext { get; set; }

        IClientForm ParentForm { get; set; }
        void Window_Closed(object sender, WindowEventArgs args);
    }

// Below is the default method implementation

    public static class IClientFormHelper
    {
        public static void SetUiContext(this IClientForm iClientForm, UIContextClass _UiContext)
        {
            iClientForm.UIContext = _UiContext;  // I put a breakpoint here and it's never hit
            iClientForm.FormId = _UiContext.AppContext.ClientGetUniqueFormId();
            iClientForm.UIContext.AddForm(iClientForm);
            iClientForm.OnClosed += iClientForm.UIContext.Window_Closed;
        }
    }
The main problem I see right now is that the default method code never runs. I assume the code is supposed to run as soon as I call the setter for UIContext that's declared in the main interface.
Apparently, this is something I don't understand.

What I want is for every IClientForm window to run the default code whenever the UIContext setter is called for that form, so that each separate window class doesn't need the same code repeated inside of it.

Can someone spot what I've done wrong and point me in the right direction? I sincerely appreciate your time.
The difficult we do right away...
...the impossible takes slightly longer.

AnswerRe: Interface with a default implementation Pin
Luc Pattyn28-Sep-24 1:14
sitebuilderLuc Pattyn28-Sep-24 1:14 
GeneralRe: Interface with a default implementation Pin
Richard Andrew x6421hrs 28mins ago
professionalRichard Andrew x6421hrs 28mins ago 
GeneralRe: Interface with a default implementation Pin
Luc Pattyn21hrs 14mins ago
sitebuilderLuc Pattyn21hrs 14mins ago 
GeneralRe: Interface with a default implementation Pin
Richard Andrew x6420hrs 30mins ago
professionalRichard Andrew x6420hrs 30mins ago 
GeneralRe: Interface with a default implementation Pin
Luc Pattyn20hrs 28mins ago
sitebuilderLuc Pattyn20hrs 28mins ago 
GeneralRe: Interface with a default implementation Pin
Richard Andrew x6420hrs 19mins ago
professionalRichard Andrew x6420hrs 19mins ago 
GeneralRe: Interface with a default implementation Pin
Luc Pattyn20hrs 14mins ago
sitebuilderLuc Pattyn20hrs 14mins ago 
AnswerRe: Interface with a default implementation Pin
jschell7mins ago
jschell7mins ago 
QuestionWhy doesn't Console.Writeline write to the debugger in .NET 8? Pin
Richard Andrew x6426-Sep-24 4:07
professionalRichard Andrew x6426-Sep-24 4:07 
AnswerRe: Why doesn't Console.Writeline write to the debugger in .NET 8? Pin
Ravi Bhavnani26-Sep-24 4:44
professionalRavi Bhavnani26-Sep-24 4:44 
GeneralRe: Why doesn't Console.Writeline write to the debugger in .NET 8? Pin
Richard Andrew x6426-Sep-24 5:33
professionalRichard Andrew x6426-Sep-24 5:33 
QuestionGame Pin
Homam Obedo25-Sep-24 10:45
Homam Obedo25-Sep-24 10:45 
AnswerRe: Game Pin
jeron125-Sep-24 10:54
jeron125-Sep-24 10:54 
AnswerRe: Game Pin
OriginalGriff25-Sep-24 19:42
mveOriginalGriff25-Sep-24 19:42 
QuestionHow do I check for existance or clear the contents of a SharePoint List from C# code? Pin
Xarzu19-Sep-24 7:58
Xarzu19-Sep-24 7:58 
AnswerRe: How do I check for existance or clear the contents of a SharePoint List from C# code? Pin
charles henington20-Sep-24 9:26
charles henington20-Sep-24 9:26 

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.