
C#能不能像PHP一样定义数组???
比如PHP的数组$MyArray=Array("字符下标"=>"String数据类型",1=>"int下标,元素为int数据类型");可不可像PHP这样定义,有什么方法?...
比如PHP的数组
$MyArray = Array(
"字符下标" => "String数据类型",
1 => "int下标,元素为int数据类型"
);
可不可像PHP这样定义,有什么方法???
pss1985你的意思是建二个数组???我要的是一个数组里面包含多种数据类型,还要String型下标。 展开
$MyArray = Array(
"字符下标" => "String数据类型",
1 => "int下标,元素为int数据类型"
);
可不可像PHP这样定义,有什么方法???
pss1985你的意思是建二个数组???我要的是一个数组里面包含多种数据类型,还要String型下标。 展开
6个回答
展开全部
你可以用ArrayList,里面是object型,什么类型都能放,然后按key来取值,key也是object型的。怎么用都行。
当然也可以用HashTable,HashTable还是线性安全的。
具体的你可以看msdn中关于
System.Collections.ArrayList 和
System.Collections.Hashtable
的资料
当然也可以用HashTable,HashTable还是线性安全的。
具体的你可以看msdn中关于
System.Collections.ArrayList 和
System.Collections.Hashtable
的资料
展开全部
ArrayList aList= new ArrayList();
aList.Add("a");
aList.Add("b");
aList.Add("c");
aList.Add("d");
aList.Add("e");
aList.Add("a");
aList.Add("b");
aList.Add("c");
aList.Add("d");
aList.Add("e");
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
C#3.5
class MyData
{
public string Name{get;set;}
public int Index{get;set;}
}
static void Main()
{
List<MyData> MyArray = new List<MyData>();
MyArray.Add(new MyData{ Name="Jack", Index=1 });
MyArray.Add(new MyData{ Name="Teddy", Index=2 });
MyArray.Add(new MyData{ Name="Tom", Index=3 });
}
class MyData
{
public string Name{get;set;}
public int Index{get;set;}
}
static void Main()
{
List<MyData> MyArray = new List<MyData>();
MyArray.Add(new MyData{ Name="Jack", Index=1 });
MyArray.Add(new MyData{ Name="Teddy", Index=2 });
MyArray.Add(new MyData{ Name="Tom", Index=3 });
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
string[] 变量名=(wgwgw,wg,wg,wgw,)
int[] 变量名=(32,342,3423,23423,)
string[] 变量名=string[2]{"a","d"};
int[] 变量名=(32,342,3423,23423,)
string[] 变量名=string[2]{"a","d"};
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
string[] a={"a","b","c"};
a[0],a[1],a[2]
那你还是用集合吧.
HashTable,SortedList都可以的哟...
a[0],a[1],a[2]
那你还是用集合吧.
HashTable,SortedList都可以的哟...
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
string[] 变量名=(wgwgw,wg,wg,wgw,)
int[] 变量名=(32,342,3423,23423,)
int[] 变量名=(32,342,3423,23423,)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询