在c#中重新保存 [英] redim preserve in c#

查看:80
本文介绍了在c#中重新保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

c#中的类似函数是什么,比如VB中的redim preserve。



我们正在开发.net c#wcf服务来自现有的旧VB6代码,以便根据我们现有代码的情况或条件..我不能使用System.Array.Copy



任何身体hv可行的方式......?

What is the similar function in c# like redim preserve which is in VB.

As we are developing .net c# wcf service from existing old VB6 code so as per our situation or condition of existing code.. I can't use System.Array.Copy

Any body hv feasable way...?

推荐答案

正如您所发现的,C#中的数组是不可变的,这意味着您无法扩展它。您可以通过以下方式之一解决问题:



1.使用自动增长的通用列表。

2.复制你的将数组放入一个临时数组中,以更大的大小创建一个新的原始数组实例并将值复制回来。
As you have discovered, an array in C# is immutable which means that you can't extend it. You can solve your problem in one of the following ways:

1. Use a generic list which grows automatically.
2. Copy your array into a temporary array, create a new instance of the original array at a larger size and copy the values back in.


AFAIK,c#中没有任何方法可以模拟VB的redim保留。

您可以使用ArrayList。
AFAIK, there is no method in c# which imulate redim preserve of VB.
You can use ArrayList instead.


这篇关于在c#中重新保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆