Click here to Skip to main content
15,899,825 members
Home / Discussions / C#
   

C#

 
GeneralRe: Convert DateTimeOffset to DateTime in Linq To Entities Pin
Pete O'Hanlon17-Jan-17 5:56
mvePete O'Hanlon17-Jan-17 5:56 
GeneralRe: Convert DateTimeOffset to DateTime in Linq To Entities Pin
Kevin Marois17-Jan-17 5:57
professionalKevin Marois17-Jan-17 5:57 
AnswerRe: Convert DateTimeOffset to DateTime in Linq To Entities Pin
Richard Deeming17-Jan-17 2:34
mveRichard Deeming17-Jan-17 2:34 
GeneralRe: Convert DateTimeOffset to DateTime in Linq To Entities Pin
Kevin Marois17-Jan-17 5:19
professionalKevin Marois17-Jan-17 5:19 
GeneralRe: Convert DateTimeOffset to DateTime in Linq To Entities Pin
Richard Deeming17-Jan-17 8:29
mveRichard Deeming17-Jan-17 8:29 
QuestionShow checkbox check in the datagridview line Pin
abboudi_ammar16-Jan-17 10:53
abboudi_ammar16-Jan-17 10:53 
AnswerRe: Show checkbox check in the datagridview line Pin
Richard MacCutchan16-Jan-17 21:37
mveRichard MacCutchan16-Jan-17 21:37 
QuestionHow can I extract positive word(s) from a paragraph in c# -Natural Language processing . Pin
Nowfal Sharafudeen16-Jan-17 1:09
Nowfal Sharafudeen16-Jan-17 1:09 
AnswerRe: How can I extract positive word(s) from a paragraph in c# -Natural Language processing . Pin
Pete O'Hanlon16-Jan-17 1:21
mvePete O'Hanlon16-Jan-17 1:21 
AnswerRe: How can I extract positive word(s) from a paragraph in c# -Natural Language processing . Pin
Eddy Vluggen16-Jan-17 2:48
professionalEddy Vluggen16-Jan-17 2:48 
Questionproject file associated with c# application on start Pin
Member 1104538814-Jan-17 22:40
Member 1104538814-Jan-17 22:40 
AnswerRe: project file associated with c# application on start Pin
Eddy Vluggen15-Jan-17 0:52
professionalEddy Vluggen15-Jan-17 0:52 
GeneralRe: project file associated with c# application on start Pin
Member 1104538815-Jan-17 1:01
Member 1104538815-Jan-17 1:01 
GeneralRe: project file associated with c# application on start Pin
Eddy Vluggen15-Jan-17 1:06
professionalEddy Vluggen15-Jan-17 1:06 
GeneralRe: project file associated with c# application on start Pin
Member 1104538815-Jan-17 1:10
Member 1104538815-Jan-17 1:10 
GeneralRe: project file associated with c# application on start Pin
Eddy Vluggen15-Jan-17 1:24
professionalEddy Vluggen15-Jan-17 1:24 
GeneralRe: project file associated with c# application on start Pin
Member 1104538815-Jan-17 1:48
Member 1104538815-Jan-17 1:48 
GeneralRe: project file associated with c# application on start Pin
OriginalGriff15-Jan-17 1:23
mveOriginalGriff15-Jan-17 1:23 
GeneralRe: project file associated with c# application on start Pin
Eddy Vluggen15-Jan-17 1:25
professionalEddy Vluggen15-Jan-17 1:25 
QuestionCan't understand implementation of interface Pin
Mc_Topaz14-Jan-17 3:07
Mc_Topaz14-Jan-17 3:07 
AnswerRe: Can't understand implementation of interface Pin
OriginalGriff14-Jan-17 3:48
mveOriginalGriff14-Jan-17 3:48 
PraiseRe: Can't understand implementation of interface Pin
Mc_Topaz14-Jan-17 4:35
Mc_Topaz14-Jan-17 4:35 
GeneralRe: Can't understand implementation of interface Pin
OriginalGriff14-Jan-17 4:46
mveOriginalGriff14-Jan-17 4:46 
SuggestionRe: Can't understand implementation of interface Pin
Richard Deeming16-Jan-17 2:18
mveRichard Deeming16-Jan-17 2:18 
AnswerRe: Can't understand implementation of interface Pin
BillWoodruff17-Jan-17 16:49
professionalBillWoodruff17-Jan-17 16:49 
Everything declared in an Interface, when you implement it in a class, must have the access modifier 'public. This "default" implementation syntax can be called implicit implementation.

The exception, which does confuse people, is the special case where you have a class that implements more than one Interface and identical names are used in each Interface, and you need to make it clear, for a duplicated name implementation, which Interface your implementation refers to.

So, when explicit implementation is used: no modifiers are allowed; and, the Interface name is followed by a dot, and the declaration.

The examples here should make this clear: [^].

If you are one of those curious persons who dares ask why you can't have access modifiers in Interfaces, and/or why you can't use other modifiers than 'public in your implementation of Interfaces; you may wish to read this thread: [^].

Suppose your class implements one Interface, and you make every implementation explicit:
public interface IStuff
{
    void SPB(string a, DateTime d, string c);
    void P(decimal a, string r);
    void EPB();

    string Name { set; get; }
}

public class Test : IStuff
{
    void IStuff.SPB(string a, DateTime d, string c)
    {
        throw new NotImplementedException();
    }

    void IStuff.P(decimal a, string r)
    {
        throw new NotImplementedException();
    }

    void IStuff.EPB()
    {
        throw new NotImplementedException();
    }

    private string _name;

    string IStuff.Name
    {
        get { return _name; }
        set { _name = value; }
    }
}
When you create an instance of this class, none of its methods, and its one field, can be accessed from the instance: you'll have to cast the instance to the Interface:
// in some method, or class initializer, or eventhandler:
var test = new Test();

// causes error
// test.Name = "fail";

// okay
(test as IStuff).name = "wtf ?";

«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008


modified 18-Jan-17 2:48am.

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.