PDA

Click to See Complete Forum and Search --> : Get and Set Help [RESOLVED]


Dilvid
Feb 23rd, 2006, 06:11 AM
Lo all,
having a little trouble with a few get and set properties im trying to do, ther reason why is they are part of an array. I can do this is vb6 pretty easy but dont know how to do it in C#.

Can someone point me in the right direction, currently I have this which is how it would be done if acAccountNote wasnt an array but unfortunatly it is hehe. Any ideas how to do this with an array??


private string AccountNote
{
get
{
return acAccountNote;
}
set
{
acAccountNote = value;
}
}

Shuja Ali
Feb 23rd, 2006, 06:20 AM
First of all I am confused. If you are creating a property why would it be private?

To have the property use array, you will need to declare the property as array
//private member that will hold the data
private string[] acAccountNote;
public string[] AccountNote
{
get
{
return acAccountNote;
}
set
{
acAccountNote = value;
}
}

mendhak
Feb 23rd, 2006, 06:21 AM
You can try

public const int intCount = 10;
private static string[] _strArr = new int[intCount];

public static string [] MYPROPERTY
{
get { return _strArr; }
set { _strArr = value; }
}


But it'd be better to use an ArrayList or a similar collection.

Dilvid
Feb 23rd, 2006, 06:23 AM
First of all I am confused. If you are creating a property why would it be private?

To have the property use array, you will need to declare the property as array
//private member that will hold the data
private string[] acAccountNote;
public string[] AccountNote
{
get
{
return acAccountNote;
}
set
{
acAccountNote = value;
}
}

oops sorry lol, it is public in my code just I typed it wrong on this hehe. guess i should start copy and pasting :bigyello: Thanks for the help it works now!!