Click here to Skip to main content
15,902,763 members
Home / Discussions / C#
   

C#

 
GeneralRe: Select all Text in TextBox and Set cursor to Start Pin
StyleGuide27-Oct-08 3:09
StyleGuide27-Oct-08 3:09 
GeneralRe: Select all Text in TextBox and Set cursor to Start Pin
DaveyM696-Nov-08 14:03
professionalDaveyM696-Nov-08 14:03 
GeneralRe: Select all Text in TextBox and Set cursor to Start Pin
#realJSOP27-Oct-08 2:40
professional#realJSOP27-Oct-08 2:40 
GeneralRe: Select all Text in TextBox and Set cursor to Start Pin
StyleGuide27-Oct-08 3:10
StyleGuide27-Oct-08 3:10 
QuestionHow to retrieve sql database tables from the server for web application Pin
anithagaraga26-Oct-08 23:24
anithagaraga26-Oct-08 23:24 
AnswerRe: How to retrieve sql database tables from the server for web application Pin
Eddy Vluggen27-Oct-08 1:31
professionalEddy Vluggen27-Oct-08 1:31 
GeneralRe: How to retrieve sql database tables from the server for web application Pin
anithagaraga28-Oct-08 20:53
anithagaraga28-Oct-08 20:53 
Questionget/set properties with arrays Pin
Dewald26-Oct-08 22:40
Dewald26-Oct-08 22:40 
Hi all,

Could someone perhaps give me a little more insight into the workings of the get and set properties?

Let's say I have the following class:

public class MyClass
{
    private byte[] _myArray;

    public byte[] MyArray
    {
        get { return _myArray; }
        set { _myArray = value; }
    }

    public MyClass()
    {
        _myArray = new byte[10];
    }
}


I can now access the member array of the class as follows:
byte[] NewArray = MyInstanceOfClass.MyArray;
and I can set it as follows:
MyInstanceOfClass.MyArray = new byte[] {0,1,2,3,4,5,6,7,8,9};
or
MyInstanceOfClass.MyArray = NewArray;

In all three examples I'm accessing the entire array as a unit. Is it also correct to access only individual elements of the array? Does the get/set properties allow for that or am I supposed to set them up differently?

By writing a little test app it seems to be working but is this the correct way of doing it?

byte MyByte = MyInstanceOfClass.MyArray[5];
and
MyInstanceOfArray.MyArray[5] = 123;
AnswerRe: get/set properties with arrays Pin
leppie26-Oct-08 22:45
leppie26-Oct-08 22:45 
GeneralRe: get/set properties with arrays Pin
Nagy Vilmos27-Oct-08 3:20
professionalNagy Vilmos27-Oct-08 3:20 
GeneralRe: get/set properties with arrays Pin
Dewald27-Oct-08 3:41
Dewald27-Oct-08 3:41 
GeneralRe: get/set properties with arrays Pin
Nagy Vilmos27-Oct-08 4:34
professionalNagy Vilmos27-Oct-08 4:34 
GeneralRe: get/set properties with arrays Pin
Dewald27-Oct-08 3:30
Dewald27-Oct-08 3:30 
GeneralRe: get/set properties with arrays Pin
Mark Salsbery27-Oct-08 5:18
Mark Salsbery27-Oct-08 5:18 
GeneralRe: get/set properties with arrays Pin
Dewald27-Oct-08 5:38
Dewald27-Oct-08 5:38 
Questionmethod in interface Pin
George_George26-Oct-08 21:20
George_George26-Oct-08 21:20 
AnswerRe: method in interface Pin
Guffa26-Oct-08 22:39
Guffa26-Oct-08 22:39 
GeneralRe: method in interface Pin
George_George27-Oct-08 1:42
George_George27-Oct-08 1:42 
GeneralRe: method in interface Pin
DaveyM6927-Oct-08 2:53
professionalDaveyM6927-Oct-08 2:53 
GeneralRe: method in interface Pin
George_George27-Oct-08 3:44
George_George27-Oct-08 3:44 
GeneralRe: method in interface Pin
DaveyM6927-Oct-08 4:12
professionalDaveyM6927-Oct-08 4:12 
GeneralRe: method in interface Pin
George_George30-Oct-08 3:29
George_George30-Oct-08 3:29 
Questionstrongly named assembly issue Pin
George_George26-Oct-08 20:51
George_George26-Oct-08 20:51 
QuestionGet list of all emails in outlook / windows mail / express client Pin
EliottA26-Oct-08 16:22
EliottA26-Oct-08 16:22 
AnswerRe: Get list of all emails in outlook / windows mail / express client Pin
Thomas Stockwell27-Oct-08 1:51
professionalThomas Stockwell27-Oct-08 1:51 

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.