Click here to Skip to main content
15,896,111 members
Home / Discussions / C#
   

C#

 
Questionderive from IEnumerator<t></t> Pin
George_George3-May-08 3:28
George_George3-May-08 3:28 
AnswerRe: derive from IEnumerator Pin
adamzhang3-May-08 3:49
adamzhang3-May-08 3:49 
GeneralRe: derive from IEnumerator Pin
George_George3-May-08 4:00
George_George3-May-08 4:00 
AnswerRe: derive from IEnumerator Pin
Pete O'Hanlon3-May-08 9:49
mvePete O'Hanlon3-May-08 9:49 
GeneralRe: derive from IEnumerator Pin
George_George3-May-08 19:40
George_George3-May-08 19:40 
GeneralRe: derive from IEnumerator Pin
Roger Alsing4-May-08 8:20
Roger Alsing4-May-08 8:20 
GeneralRe: derive from IEnumerator Pin
George_George6-May-08 3:07
George_George6-May-08 3:07 
Questionprivate/public get/set Pin
George_George3-May-08 2:51
George_George3-May-08 2:51 
Hello everyone,


New to C#, a simple question which my book does not cover.

If we do not specify the public/private access of get/set, then it is of the same as the public/private access to the property itself, but we can overwrite it.

For example, in the following code, in get method, when we do not specify public/private, it will be automatically the same as the property Abc, which makes get public, but in set, we can overwrite it to make it private?

public class MyList
{

    class Foo
    {
        private int _abc;

        public int Abc
        {
            get
            {
                return _abc;
            }
            private set
            {
                _abc = value;
            }
        }

    }

    static void Main()
    {
        Foo f = new Foo();
        return;
    }
}



thanks in advance,
George
AnswerRe: private/public get/set Pin
#realJSOP3-May-08 3:17
professional#realJSOP3-May-08 3:17 
GeneralRe: private/public get/set Pin
George_George3-May-08 3:19
George_George3-May-08 3:19 
GeneralRe: private/public get/set Pin
adamzhang3-May-08 3:54
adamzhang3-May-08 3:54 
GeneralRe: private/public get/set Pin
George_George3-May-08 4:01
George_George3-May-08 4:01 
GeneralRe: private/public get/set Pin
carbon_golem3-May-08 4:22
carbon_golem3-May-08 4:22 
GeneralRe: private/public get/set Pin
George_George3-May-08 4:39
George_George3-May-08 4:39 
GeneralRe: private/public get/set Pin
Rob Graham3-May-08 4:56
Rob Graham3-May-08 4:56 
GeneralRe: private/public get/set Pin
George_George3-May-08 5:04
George_George3-May-08 5:04 
GeneralRe: private/public get/set Pin
PIEBALDconsult4-May-08 5:29
mvePIEBALDconsult4-May-08 5:29 
GeneralRe: private/public get/set Pin
George_George4-May-08 19:44
George_George4-May-08 19:44 
GeneralRe: private/public get/set Pin
PIEBALDconsult5-May-08 12:15
mvePIEBALDconsult5-May-08 12:15 
GeneralRe: private/public get/set Pin
George_George6-May-08 4:04
George_George6-May-08 4:04 
GeneralRe: private/public get/set Pin
PIEBALDconsult6-May-08 13:17
mvePIEBALDconsult6-May-08 13:17 
GeneralRe: private/public get/set Pin
George_George7-May-08 2:40
George_George7-May-08 2:40 
GeneralRe: private/public get/set Pin
PIEBALDconsult7-May-08 13:04
mvePIEBALDconsult7-May-08 13:04 
GeneralRe: private/public get/set Pin
George_George7-May-08 22:34
George_George7-May-08 22:34 
AnswerRe: private/public get/set Pin
PIEBALDconsult3-May-08 4:35
mvePIEBALDconsult3-May-08 4:35 

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.