| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1021 人关注过本帖
标题:asp.net页面怎样发送一个ArrayList对象给winform应用程序
只看楼主 加入收藏
loveqq2004
Rank: 1
等 级:新手上路
帖 子:76
专家分:0
注 册:2006-8-28
收藏
 问题点数:0 回复次数:3 
asp.net页面怎样发送一个ArrayList对象给winform应用程序
ArrayList myAL = new ArrayList();
myAL.Add("Hello");
myAL.Add("World");
myAL.Add("!");
怎样把这个myAL发送给winform应用程序,还有winform应用程序怎么接收并还原成ArrayList对象?
请教,谢谢!
搜索更多相关主题的帖子: ArrayList 应用程序 winform myAL 对象 
2007-01-31 16:56
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 

ArrayList 类
使用大小可按需动态增加的数组实现 IList 接口。

命名空间:System.Collections
程序集:mscorlib(在 mscorlib.dll 中)

语法

Visual Basic(声明)
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Class ArrayList
Implements IList, ICollection, IEnumerable, ICloneable

Visual Basic(用法)
Dim instance As ArrayList

C#
[SerializableAttribute]
[ComVisibleAttribute(true)]
public class ArrayList : IList, ICollection, IEnumerable,
ICloneable

C++
[SerializableAttribute]
[ComVisibleAttribute(true)]
public ref class ArrayList : IList, ICollection, IEnumerable,
ICloneable

J#
/** @attribute SerializableAttribute() */
/** @attribute ComVisibleAttribute(true) */
public class ArrayList implements IList, ICollection,
IEnumerable, ICloneable

JScript
SerializableAttribute
ComVisibleAttribute(true)
public class ArrayList implements IList, ICollection,
IEnumerable, ICloneable

备注

不保证会对 ArrayList 排序。在执行需要对 ArrayList 排序的操作(如 BinarySearch)之前,必须对 ArrayList 进行排序。

ArrayList 的容量是 ArrayList 可以保存的元素数。ArrayList 的默认初始容量为 0。随着元素添加到 ArrayList 中,容量会根据需要通过重新分配自动增加。可通过调用 TrimToSize 或通过显式设置 Capacity 属性减少容量。

使用整数索引可以访问此集合中的元素。此集合中的索引从零开始。

ArrayList 接受 空引用(在 Visual Basic 中为 Nothing) 作为有效值并且允许重复的元素。

示例

下面的代码示例演示如何创建并初始化 ArrayList 以及如何打印出其值。

Visual Basic 复制代码
Imports System
Imports System.Collections
Imports Microsoft.VisualBasic

Public Class SamplesArrayList

Public Shared Sub Main()

' Creates and initializes a new ArrayList.
Dim myAL As New ArrayList()
myAL.Add("Hello")
myAL.Add("World")
myAL.Add("!")

' Displays the properties and values of the ArrayList.
Console.WriteLine("myAL")
Console.WriteLine(" Count: {0}", myAL.Count)
Console.WriteLine(" Capacity: {0}", myAL.Capacity)
Console.Write(" Values:")
PrintValues(myAL)
End Sub

Public Shared Sub PrintValues(myList As IEnumerable)
Dim obj As [Object]
For Each obj In myList
Console.Write(" {0}", obj)
Next obj
Console.WriteLine()
End Sub 'PrintValues

End Class


' This code produces output similar to the following:
'
' myAL
' Count: 3
' Capacity: 4
' Values: Hello World !


C# 复制代码
using System;
using System.Collections;
public class SamplesArrayList {

public static void Main() {

// Creates and initializes a new ArrayList.
ArrayList myAL = new ArrayList();
myAL.Add("Hello");
myAL.Add("World");
myAL.Add("!");

// Displays the properties and values of the ArrayList.
Console.WriteLine( "myAL" );
Console.WriteLine( " Count: {0}", myAL.Count );
Console.WriteLine( " Capacity: {0}", myAL.Capacity );
Console.Write( " Values:" );
PrintValues( myAL );
}

public static void PrintValues( IEnumerable myList ) {
foreach ( Object obj in myList )
Console.Write( " {0}", obj );
Console.WriteLine();
}

}


/*
This code produces output similar to the following:

myAL
Count: 3
Capacity: f
Values: Hello World !

*/

C++ 复制代码
using namespace System;
using namespace System::Collections;
void PrintValues( IEnumerable^ myList );
int main()
{

// Creates and initializes a new ArrayList.
ArrayList^ myAL = gcnew ArrayList;
myAL->Add( "Hello" );
myAL->Add( "World" );
myAL->Add( "!" );

// Displays the properties and values of the ArrayList.
Console::WriteLine( "myAL" );
Console::WriteLine( " Count: {0}", myAL->Count );
Console::WriteLine( " Capacity: {0}", myAL->Capacity );
Console::Write( " Values:" );
PrintValues( myAL );
}

void PrintValues( IEnumerable^ myList )
{
IEnumerator^ myEnum = myList->GetEnumerator();
while ( myEnum->MoveNext() )
{
Object^ obj = safe_cast<Object^>(myEnum->Current);
Console::Write( " {0}", obj );
}

Console::WriteLine();
}

/*
This code produces output similar to the following:

myAL
Count: 3
Capacity: 4
Values: Hello World !

*/

J# 复制代码
import System.*;
import System.Collections.*;

public class SamplesArrayList
{
public static void main(String[] args)
{
// Creates and initializes a new ArrayList.
ArrayList myAL = new ArrayList();

myAL.Add("Hello");
myAL.Add("World");
myAL.Add("!");

// Displays the properties and values of the ArrayList.
Console.WriteLine("myAL");
Console.WriteLine(" Count: {0}", (Int32)myAL.get_Count());
Console.WriteLine(" Capacity: {0}", (Int32)myAL.get_Capacity());
Console.Write(" Values:");
PrintValues(myAL);
} //main

public static void PrintValues(IEnumerable myList)
{
IEnumerator objMyEnum = myList.GetEnumerator();
while (objMyEnum.MoveNext()) {
Object obj = objMyEnum.get_Current();
Console.Write(" {0}", obj);
}
Console.WriteLine();
} //PrintValues
} //SamplesArrayList
/*
This code produces output similar to the following:

myAL
Count: 3
Capacity: 4
Values: Hello World !

*/

JScript 复制代码
import System;
import System.Collections;

// Creates and initializes a new ArrayList.
var myAL : ArrayList = new ArrayList();
myAL.Add("Hello");
myAL.Add("World");
myAL.Add("!");

// Displays the properties and values of the ArrayList.
Console.WriteLine( "myAL" );
Console.WriteLine( "\tCount: {0}", myAL.Count );
Console.WriteLine( "\tCapacity: {0}", myAL.Capacity );
Console.Write( "\tValues:" );
PrintValues( myAL );


function PrintValues( myList : IEnumerable ) {
var myEnumerator : System.Collections.IEnumerator = myList.GetEnumerator();
while ( myEnumerator.MoveNext() )
Console.Write( "\t{0}", myEnumerator.Current );
Console.WriteLine();
}
/*
This code produces output similar to the following:

myAL
Count: 3
Capacity: 4
Values: Hello World !
*/


本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2007-01-31 17:27
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2007-01-31 17:28
loveqq2004
Rank: 1
等 级:新手上路
帖 子:76
专家分:0
注 册:2006-8-28
收藏
得分:0 

我的意思是,winform应用程序是客户端,他请求页面,页面把一个ArrayList对象发给客户端。
客户端怎样得到这个ArrayList对象?

2007-01-31 17:52
快速回复:asp.net页面怎样发送一个ArrayList对象给winform应用程序
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.042757 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved