Translate

Monday, October 15, 2007

How to do Redim of an array in C#

Since there's no ReDim keyword in C# then what needs to be done is that we need to write a function which does the same using an array list, this would be type specific :

private ParameterValue[] ReDimArray(ref ParameterValue[] ParameterValue,int Index)
{
TempParameterValue= new ParameterValue[Index+1];
if (TempParameterValue !=null && ParameterValue!=null)
Array.Copy(ParameterValue,TempParameterValue,Math.Min(TempParameterValue.Length,Index));

ParameterValue = TempParameterValue;
return ParameterValue;
}

VB .Net to C# converter

Had a bunch of classes written in VB so to convert it in C# go to the link

VB to C# Converter

The results were good but i won't say it was 100% fool proof. Need to review the code after converting.