Click here to Skip to main content
15,922,015 members
Home / Discussions / C#
   

C#

 
AnswerRe: Adding to multi dimension array Pin
Christian Graus19-Feb-07 10:16
protectorChristian Graus19-Feb-07 10:16 
GeneralRe: Adding to multi dimension array Pin
Leslie Sanford19-Feb-07 10:24
Leslie Sanford19-Feb-07 10:24 
GeneralRe: Adding to multi dimension array Pin
Christian Graus19-Feb-07 10:43
protectorChristian Graus19-Feb-07 10:43 
AnswerRe: Adding to multi dimension array Pin
Aaron VanWieren19-Feb-07 17:32
Aaron VanWieren19-Feb-07 17:32 
QuestionTeam Foundation Server Pin
mihksoft19-Feb-07 6:19
mihksoft19-Feb-07 6:19 
AnswerRe: Team Foundation Server Pin
Christian Graus19-Feb-07 8:55
protectorChristian Graus19-Feb-07 8:55 
QuestionInterface Properties Pin
santhony719-Feb-07 6:08
santhony719-Feb-07 6:08 
AnswerRe: Interface Properties Pin
Leslie Sanford19-Feb-07 6:27
Leslie Sanford19-Feb-07 6:27 
santhony7 wrote:
If I use both, shouldn't the interface require me to declare both?


Nope. Smile | :) Say you have a readonly (get) property declared in an interface. In your implementing class, you have to implement the property with a getter. However, the setter is optional. If you implement a setter as well, it's not covered by the interface but is rather specific to the implementing class. For example:

using System;
using System.Collections.Generic;
using System.Text;
 
namespace InterfaceTest
{
    class Program
    {
        static void Main(string[] args)
        {
            IReadThings things = new TheDoc();
 
            int s = things.Status;    // Works just fine.
 
            things.Status = 42; // Oops!!! Doesn't compile!
        }
    }
 
    interface IReadThings
    {
        int Status 
        { 
            get;
        }
    }
 
    public class TheDoc : IReadThings
    {
        int theStatus = 0;
 
        public int Status
        {
            get { return theStatus; }
            set { theStatus = value; }
        }
    } 
}


The above doesn't compile because "things" is a reference to the IReadThings interface. Thus it represents only the functionality declared by the IReadThings interface. Since IReadThings doesn't have a setter for the Status property, we get a compile error. Had we made "things" of type TheDoc, it would compile just fine.

The interface represents a blueprint that an implementing class must implement. However, the implementing class is free to provide additional functionality that goes beyond the interface's contract. This includes properties providing a getter or setter if one isn't specified by the interface.
GeneralRe: Interface Properties Pin
santhony719-Feb-07 8:58
santhony719-Feb-07 8:58 
GeneralRe: Interface Properties Pin
mike montagne19-Feb-07 14:09
mike montagne19-Feb-07 14:09 
QuestionBusiness Object Properties in Random Order Pin
Thomas Wells19-Feb-07 5:47
Thomas Wells19-Feb-07 5:47 
AnswerRe: Business Object Properties in Random Order Pin
tgrt19-Feb-07 13:12
tgrt19-Feb-07 13:12 
GeneralRe: Business Object Properties in Random Order Pin
Thomas Wells20-Feb-07 8:12
Thomas Wells20-Feb-07 8:12 
GeneralRe: Business Object Properties in Random Order Pin
tgrt20-Feb-07 9:37
tgrt20-Feb-07 9:37 
QuestionInteraction Pin
ugrasamam19-Feb-07 5:24
ugrasamam19-Feb-07 5:24 
AnswerRe: Interaction Pin
sharpiesharpie19-Feb-07 6:08
sharpiesharpie19-Feb-07 6:08 
AnswerRe: Interaction Pin
NanaAM19-Feb-07 19:53
NanaAM19-Feb-07 19:53 
AnswerRe: Interaction Pin
ugrasamam20-Feb-07 20:03
ugrasamam20-Feb-07 20:03 
QuestionNeed Help with Strange TextBox.Leave behavior Pin
Rabbit1719-Feb-07 5:05
Rabbit1719-Feb-07 5:05 
AnswerRe: Need Help with Strange TextBox.Leave behavior Pin
sharpiesharpie19-Feb-07 5:15
sharpiesharpie19-Feb-07 5:15 
GeneralRe: Need Help with Strange TextBox.Leave behavior Pin
Rabbit1719-Feb-07 6:23
Rabbit1719-Feb-07 6:23 
Questioncopy complete dir Pin
topcatalpha19-Feb-07 5:05
topcatalpha19-Feb-07 5:05 
AnswerRe: copy complete dir Pin
Pete O'Hanlon19-Feb-07 5:11
mvePete O'Hanlon19-Feb-07 5:11 
GeneralRe: copy complete dir Pin
topcatalpha19-Feb-07 5:14
topcatalpha19-Feb-07 5:14 
AnswerRe: copy complete dir Pin
NanaAM19-Feb-07 19:58
NanaAM19-Feb-07 19:58 

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.