G***G 发帖数: 16778 | 1 一个int [] m_array
如何定义get 和 set
才能在c#中如下赋值呢?
m_array[5]= 3; |
W***o 发帖数: 6519 | 2 array 本身就是mutable的,为什么还要自己写get, set? 如果真的需要脱了裤子再放
,用个wrapper不行吗?
get(index) {
return m_array[index];
}
set(index, val) {
m_array[index] = val;
}
【在 G***G 的大作中提到】 : 一个int [] m_array : 如何定义get 和 set : 才能在c#中如下赋值呢? : m_array[5]= 3;
|
G***G 发帖数: 16778 | 3 试了这个。发现在wpf里面,不能用于 binding
我需要一个checklistbox binding一个array
能get,能set
【在 W***o 的大作中提到】 : array 本身就是mutable的,为什么还要自己写get, set? 如果真的需要脱了裤子再放 : ,用个wrapper不行吗? : get(index) { : return m_array[index]; : } : set(index, val) { : m_array[index] = val; : }
|
l**********n 发帖数: 8443 | 4 observablecollection
【在 G***G 的大作中提到】 : 试了这个。发现在wpf里面,不能用于 binding : 我需要一个checklistbox binding一个array : 能get,能set
|
Y**G 发帖数: 1089 | 5
换Java吧。
http://docs.oracle.com/javase/7/docs/api/
public static void set(Object array,
int index,
Object value)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
【在 G***G 的大作中提到】 : 一个int [] m_array : 如何定义get 和 set : 才能在c#中如下赋值呢? : m_array[5]= 3;
|
N********n 发帖数: 8363 | 6
这啥玩意,手动挡TYPE ERASURE? OBJECT类型都拿出来了还咋DATA BINDING。是不
是JAVA GENERICS玩太多了?LOL
【在 Y**G 的大作中提到】 : : 换Java吧。 : http://docs.oracle.com/javase/7/docs/api/ : public static void set(Object array, : int index, : Object value) : throws IllegalArgumentException, : ArrayIndexOutOfBoundsException
|
Y**G 发帖数: 1089 | 7 是整数数组,直接用Array.setInt,跟generic有什么关系?
【在 N********n 的大作中提到】 : : 这啥玩意,手动挡TYPE ERASURE? OBJECT类型都拿出来了还咋DATA BINDING。是不 : 是JAVA GENERICS玩太多了?LOL
|
N********n 发帖数: 8363 | 8
You have to bind to either objects or public properties of an objects.
If these integers are public property of an array of objects then you
can bind it to the array w/ content being that integer property.
【在 G***G 的大作中提到】 : 试了这个。发现在wpf里面,不能用于 binding : 我需要一个checklistbox binding一个array : 能get,能set
|
N********n 发帖数: 8363 | 9
Never use "object" as types when setting values. It opens the door to
runtime errors. Only those the badly designed generics does it.
【在 Y**G 的大作中提到】 : 是整数数组,直接用Array.setInt,跟generic有什么关系?
|