about array and property
-
if i use this code, do it have no sense private int[] testProtery = new int[3]; public int[] TestProtery { get { return this.testProtery; } set { this.testProtery = value; } } i want to uee the property to match the private filed of testProtery, i feel this code don't work. please let me understand. thank you
-
if i use this code, do it have no sense private int[] testProtery = new int[3]; public int[] TestProtery { get { return this.testProtery; } set { this.testProtery = value; } } i want to uee the property to match the private filed of testProtery, i feel this code don't work. please let me understand. thank you
-
if i use this code, do it have no sense private int[] testProtery = new int[3]; public int[] TestProtery { get { return this.testProtery; } set { this.testProtery = value; } } i want to uee the property to match the private filed of testProtery, i feel this code don't work. please let me understand. thank you
sure, it'll work.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia> -------------------------------------------------------- 128 bit encrypted signature, crack if you can
-
if i use this code, do it have no sense private int[] testProtery = new int[3]; public int[] TestProtery { get { return this.testProtery; } set { this.testProtery = value; } } i want to uee the property to match the private filed of testProtery, i feel this code don't work. please let me understand. thank you
for exampel , do i use this : this.testProtery[0].TestProtery; i don't understand, thank you .
-
for exampel , do i use this : this.testProtery[0].TestProtery; i don't understand, thank you .
well it depends what you want to access? if you have, for example, an array of string for different data you might do something like the following.
private string[] stringData = new string[2];
public string Name{
get{return stringData[0];
set{stringData[0] = value;
}public string JobTitle{
get{return stringData[1];
set{stringData[1] = value;
}thou in this instance you would prob want to have two different string instances for the data
Life goes very fast. Tomorrow, today is already yesterday.
-
for exampel , do i use this : this.testProtery[0].TestProtery; i don't understand, thank you .
Ok, stay with me on this. Let's say that you have
public class TestClass
{
private int[] _field;
}Now, in a method of
TestClass
, you would have the following to reference the value of _field.public class TestClass
{
public void DoSomethingWithTheField()
{
if(null == _field)
{
this._field = new int[3]; // or just _field = new int[3];
}
}
private int[] _field;
}Now, let's add a property that allows getting and setting on
_field
.public class TestClass
{
public int[] Property
{
get { return _field; }
set { _field = value; }
}public void DoSomethingWithTheField()
{
if(null == _field)
{
this._field = new int[3]; // or just _field = new int[3];
}
}
private int[] _field;
}Now, you can have a method that will do something like this.
public class TestClass
{
public void DoSomethingWithTheProperty(int secondValue)
{
this.Property[1] = secondValue; // or Property[1] = secondValue;
}public int[] Property
{
get { return _field; }
set { _field = value; }
}public void DoSomethingWithTheField()
{
if(null == _field)
{
this._field = new int[3]; // or just _field = new int[3];
}
}
private int[] _field;
}You see? When you expose a property as an array of integers, you can just use it like an array of integers.
"we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty
-
Ok, stay with me on this. Let's say that you have
public class TestClass
{
private int[] _field;
}Now, in a method of
TestClass
, you would have the following to reference the value of _field.public class TestClass
{
public void DoSomethingWithTheField()
{
if(null == _field)
{
this._field = new int[3]; // or just _field = new int[3];
}
}
private int[] _field;
}Now, let's add a property that allows getting and setting on
_field
.public class TestClass
{
public int[] Property
{
get { return _field; }
set { _field = value; }
}public void DoSomethingWithTheField()
{
if(null == _field)
{
this._field = new int[3]; // or just _field = new int[3];
}
}
private int[] _field;
}Now, you can have a method that will do something like this.
public class TestClass
{
public void DoSomethingWithTheProperty(int secondValue)
{
this.Property[1] = secondValue; // or Property[1] = secondValue;
}public int[] Property
{
get { return _field; }
set { _field = value; }
}public void DoSomethingWithTheField()
{
if(null == _field)
{
this._field = new int[3]; // or just _field = new int[3];
}
}
private int[] _field;
}You see? When you expose a property as an array of integers, you can just use it like an array of integers.
"we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty
-
I am not getting your question. The above post is rather a statement. Can you be a little more specific?
Regards, Chandra V
I have no question. I posted a statement. I walked through the creation of a class with a field of type "integer array," a property that exposed it, and then methods that consume each. It answers the original poster's "how do I access this" question.
"we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty
-
I have no question. I posted a statement. I walked through the creation of a class with a field of type "integer array," a property that exposed it, and then methods that consume each. It answers the original poster's "how do I access this" question.
"we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty
-
You're welcome.
"we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty