Hello
got such proble (easy I think:( )
i declare variable:
private int[] var1 = new int[10];
how to write property for this variable? 5 938
Hi Damar,
Do you mean something like this?
public int[] MyProperty
{
get
{
return var1;
}
set
{
var1 = value;
}
}
On Mon, 10 Jan 2005 02:29:01 -0800, DAMAR
<DA***@discussions.microsoft.com> wrote: Hello got such proble (easy I think:( )
i declare variable: private int[] var1 = new int[10];
how to write property for this variable?
--
Happy Coding!
Morten Wennevik [C# MVP]
Yeah thanks.
I would not suppose its so easy.
I tried with indexers, but your solution is simpler
"Morten Wennevik" wrote: Hi Damar,
Do you mean something like this?
public int[] MyProperty { get { return var1; } set { var1 = value; } }
On Mon, 10 Jan 2005 02:29:01 -0800, DAMAR <DA***@discussions.microsoft.com> wrote:
Hello got such proble (easy I think:( )
i declare variable: private int[] var1 = new int[10];
how to write property for this variable? -- Happy Coding! Morten Wennevik [C# MVP]
Hi DAMAR,
Morten's solutions is easy, and it works with
simplest possible way.
Remember, that *MyProperty* property will return
and set only a "reference" to table of *int*.
e.g.:
int[] intTable=myObj.MyProperty;
intTable[2]=13;
// myObj.MyProperty[2]==13
So if you want to keep table *MyProperty* as
an independent table of int's then you should
extend *get;set* code with Array.Copy(ing).
HTH
Marcin Yeah thanks. I would not suppose its so easy. I tried with indexers, but your solution is simpler
"Morten Wennevik" wrote:
Hi Damar,
Do you mean something like this?
public int[] MyProperty { get { return var1; } set { var1 = value; } }
On Mon, 10 Jan 2005 02:29:01 -0800, DAMAR <DA***@discussions.microsoft.com> wrote:
Hello got such proble (easy I think:( )
i declare variable: private int[] var1 = new int[10];
how to write property for this variable? -- Happy Coding! Morten Wennevik [C# MVP]
would u help me how to write it? ArrayCopy?
"Marcin Grzębski" wrote: Hi DAMAR,
Morten's solutions is easy, and it works with simplest possible way. Remember, that *MyProperty* property will return and set only a "reference" to table of *int*. e.g.:
int[] intTable=myObj.MyProperty; intTable[2]=13; // myObj.MyProperty[2]==13
So if you want to keep table *MyProperty* as an independent table of int's then you should extend *get;set* code with Array.Copy(ing).
HTH Marcin
Yeah thanks. I would not suppose its so easy. I tried with indexers, but your solution is simpler
"Morten Wennevik" wrote:
Hi Damar,
Do you mean something like this?
public int[] MyProperty { get { return var1; } set { var1 = value; } }
On Mon, 10 Jan 2005 02:29:01 -0800, DAMAR <DA***@discussions.microsoft.com> wrote:
Hello got such proble (easy I think:( )
i declare variable: private int[] var1 = new int[10];
how to write property for this variable? -- Happy Coding! Morten Wennevik [C# MVP]
It would be something like this
private int[] myints;
public int[] MyProperty
{
get
{
int[] temparray = new int[myints.Length];
Array.Copy(myints, temparray, myints.Length);
return temparray;
}
set
{
myints = new int[value.Length];
Array.Copy(value, myints, value.Length);
}
}
On Thu, 13 Jan 2005 02:35:03 -0800, DAMAR
<DA***@discussions.microsoft.com> wrote: would u help me how to write it? ArrayCopy?
"Marcin Grzębski" wrote:
Hi DAMAR,
Morten's solutions is easy, and it works with simplest possible way. Remember, that *MyProperty* property will return and set only a "reference" to table of *int*. e.g.:
int[] intTable=myObj.MyProperty; intTable[2]=13; // myObj.MyProperty[2]==13
So if you want to keep table *MyProperty* as an independent table of int's then you should extend *get;set* code with Array.Copy(ing).
HTH Marcin
> Yeah thanks. > I would not suppose its so easy. > I tried with indexers, but your solution is simpler > > "Morten Wennevik" wrote: > > >>Hi Damar, >> >>Do you mean something like this? >> >>public int[] MyProperty >>{ >> get >> { >> return var1; >> } >> set >> { >> var1 = value; >> } >>} >> >> >>On Mon, 10 Jan 2005 02:29:01 -0800, DAMAR >><DA***@discussions.microsoft.com> wrote: >> >> >>>Hello >>>got such proble (easy I think:( ) >>> >>>i declare variable: >>>private int[] var1 = new int[10]; >>> >>>how to write property for this variable? >>> >>> >>> >> >> >> >>-- >>Happy Coding! >>Morten Wennevik [C# MVP] >>
--
Happy Coding!
Morten Wennevik [C# MVP] This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mevar81 |
last post by:
Hi to everybody.I have a problem with the PropertyGrid
control.I want to display not all the properties of a
generic Control(Button,TextBox,ComboBox,ecc.).In general
I don't want to display only...
|
by: wASP |
last post by:
Hi,
I've got a pair of int properties in a class.
The properties in question are indexing values
- but that's not relevant to my problem
- or it's just symptomatic ... sort of.
They are...
|
by: Lucas, Todd |
last post by:
Hello everyone! I'm having a problem with a WebControl that I'm designing
for a Menu. I've been at it for about 3 weeks now, and can't seem to get
around this problem. So I'm hoping that someone...
|
by: Marc |
last post by:
So I am having some issues with code written by another developer that
interfaces with Active Directory. We had a catastrophic failure on the
server and had to recreate the AD. No the following...
|
by: Tim::.. |
last post by:
Hi...
I'm having a big problem with a datagrid that obtains data from 2 different
locations...
Active Directory and SQL Database
The data is inserted into a datatable and the sorted by a...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |