Home » VB.Net

It is possible to declare an array as constant


I try to convert a Java Projekt in vb.


Can I declare in vb an array as constant.


The Java code looks like this

 final byte[] tmp=new byte[4];

What I did, was:

Const tmp(3) As Byte

What is wrong with that?


2 Answers Found


Answer 1

static readonly tmp(3) as byte



Answer 2

static readonly tmp(3) as byte

Another .NET approach would also be to declare  an enumeration.  This is the more OOP approach than a global array.

Public Enum MyByteConstants As Byte
  First = 1
  Second = 2
  Third = 4
  Fourth = 8
End Enum

You can also add the Flags atrribute, too.

Rudy  =8^D



Hello,  Please help me understand why I am getting the following error message with the following code:


The Code:

 Partial Class test2
    Inherits System.Web.UI.Page
    Const ICEVarUsername = User.Identity.Name
    Dim ICEVarPubName as String
    Dim ICEVarUsersJoinDate as String

The Error Message:

Error 1 Reference to a non-shared member requires an object reference


So I tried:

Partial Class test2
    Inherits System.Web.UI.Page
    Const ICEVarUsername as Object = User.Identity.Name

But I still got the same exact Error Message


I am doing this because I have a form that a user will fill out to create an account on my website, but I want to make sure that they are already a registered user, so when I created the table that the new account info is going into, the SQL for the created the table is :

sql_create = "CREATE TABLE " & _
 "tbl_PrivateAccount (username nvarchar(256) NOT NULL," & _
"thisuser uniqueidentifier NOT NULL PRIMARY KEY," & _
"public_UsersName varchar(255) NOT NULL," & _
"usersJoinDate datetime NOT NULL)"

 So later when I insert their info into the table, I want to fill username with the value of  ICEVarUsername (meaning the currents users name)

That way, so in the future, whenever that person wants to change information in PrivateAccount table, they will have to first be logged in with the same user name!

The Insert Statement  is as follows:

sql_insert = "INSERT INTO tbl_PrivateAccount (username, public_UserName, usersJoinDate) values (ICEVarUsername, ICEVarPubName, ICEVarUsersJoinDate)"

ICEVarPubName and ICEVarUsersJoinDate are declared variables

ICEVarPubName has a value assigned to it from a text box control's Text Property

ICEVarUsersJoinDate has the following data assigned to it :  ICEVarUsersJoinDate = DateAndTime.Now

Remember, the only error I am getting is the 1 Error = Error 1 Reference to a non-shared member requires an object reference

Please Help.  If you even have an easier way to do this please let me know, but I ask that you don't ASSUME I know what you are talking about, please explain your information in a "For Dummies" format.



I first declare my custom enumeration, TargetAudience.  I then try to make a constant of type TargetAudience and I receive an immediate compile error complaining about missing syntax.

Public Enum TargetAudience
  EngineSW = 1
  VibrationGroup = 2
End Enum
Public g_TargetAudience As TargetAudience ' Works fine as expected
public const doomedToFail as TargetAudience = EngineSW 'IDE highlights TargetAudience and gives me this error "Compile error: Expected: name type"

 Any help would be greatly appreciated.

Thank you



I'm trying to make a program of arrays ,In which i make a variable array, i mean i let the user choose the size of the array, and this is the program and i will say the problem after it

using namespace std;

int main ()
int z ;
cin>>z ;
int x[z];
for(int i=0;i<z;i++){

for(int j=0;j<z;j++){

return 0;


the problem is in the line


int x[z];


and i don't know what to do , whatever i used this method many times before on many other compilers to allow the user to choose the size of the array while now it give me an error

I'm using Microsoft Visual C++ 2010

I'm waiting your hlep

And Thnx in advanced


Hi I have an application which I have worked on several times, but this week I've been trying to get the application to work on a new laptop and failed.

First there were was some dependency issues with some controls like the AJAX Control Toolkit and AJAX Extensions, but now that I have everything I'm still getting errors.

The errors that I'm getting are only in the App_Code classes.

For Example I have the following references in the web.config

                <add namespace="System"/>
                <add namespace="System.Collections"/>
                <add namespace="System.Collections.Specialized"/>
                <add namespace="System.Configuration"/>
                <add namespace="System.Text"/>
                <add namespace="System.Text.RegularExpressions"/>
                <add namespace="System.Web"/>
                <add namespace="System.Web.Caching"/>
                <add namespace="System.Web.SessionState"/>
                <add namespace="System.Web.Security"/>
                <add namespace="System.Web.Profile"/>
                <add namespace="System.Web.UI"/>
                <add namespace="System.Web.UI.WebControls"/>
                <add namespace="System.Web.UI.WebControls.WebParts"/>
                <add namespace="System.Web.UI.HtmlControls"/>

The following Imports in my class:

Imports System.Data.SqlClient
Imports System.Data
Imports System
Imports System.Web

Now from my tests I've realized that the classes in the App_Code can't reference all of the classes that can be referenced from the code behind files (aspx.vb)

For example in a code behind file I can fetch a conection string like so:


And I can import the namespace like so:

Imports System.Configuration.ConfigurationManager

But if I try the above in the Classes that are inside the App_Code I get Type ConfigurationManager is not declared

and ConfigurationManager is not available from the Imports.

Now the ConfigurationManager is available in the Property Pages.

Also this error was apearing with the Exception class and HttoContext class as well, but this was solved by importing System and System.Web

I even tried adding System.Configuration like so in the web.config:

<add assembly="System.Configuration, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

But this didn't help.

So I'm basically getting tons of errors (over 100) for missing references.

Any ideas?

Thank you


Hi guys my task to switch the positions of pixels to distort an image

i heard when you want to switch a pixel with pixel you have to switch the rgb colors thats why i thought need the rgb value of the pixel. is that the correct direction for me to work on?

for example i want to switch position A with position B i would need another variable such as position C so that when i switch from position A to position B my position A value wont be lost

such as A = 2
B = 3
C = unknown

i move C = A
A = B
B = C

is that the correct way? please advise. I know how to work out in theory but i am very poor with Visual Basic therefore need help with coding

 i need help with inserting Bitmap into array I have done that part but i do not know if that is correct

this will allow me extraction of pixel from the array and finally taking out the RGB Colors and swapping the RGB colors to switch the pixels position

Below is the codes that i am having so far










Class Form1


PublicFunction CopyDataToBitmap(ByVal data AsByte()) As Bitmap


'Here create the Bitmap to the know height, width and format


Dim bmp AsNew Bitmap(640, 480, PixelFormat.Format24bppRgb)


'Create a BitmapData and Lock all pixels to be written


Dim bmpData As BitmapData = bmp.LockBits(New Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.[WriteOnly], bmp.PixelFormat)


'Copy the data from the byte array into BitmapData.Scan0

Marshal.Copy(data, 0, bmpData.Scan0, data.Length)



'Unlock the pixels




'Return the bitmap


Return bmp




Dim I1 As Bitmap


Dim Cx, Cy, TF, mp, o(256), grn(256), blue(256), red(256) AsInteger


Dim I4 As Bitmap


Dim a AsInteger = 0


Dim check AsBoolean = False


'Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


'Dim I3 As Bitmap = New Bitmap(I1.Width, I1.Height)


'Dim I4 As Bitmap = New Bitmap(I1.Width, I1.Height)


'End Sub


PrivateFunction CropBitmap(ByRef bmp As Bitmap, ByVal cropX AsInteger, ByVal cropY AsInteger, ByVal cropWidth AsInteger, ByVal cropHeight AsInteger) As Bitmap


Dim rect AsNew Rectangle(cropX, cropY, cropWidth, cropHeight)


Dim cropped As Bitmap = bmp.Clone(rect, bmp.PixelFormat)


Return cropped




PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


Dim ReadingFileDialog AsNew OpenFileDialog


Dim fileOpened AsBoolean = False


If fileOpened = TrueThen


fileOpened =




ReadingFileDialog.Title =

"Open My File"


' Restrict our choice of files to *.jpeg files.

ReadingFileDialog.Filter =

"Bitmap *.bmp|*.bmp|JPEG *.jpg|*.jpg|GIF *.gif|*.gif"


If ReadingFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then



fileOpened =



Dim IPB As Bitmap = New Bitmap(ReadingFileDialog.FileName)


If ReadingFileDialog.FileName <> ""Then

PictureBox1.Image =

New Bitmap(ReadingFileDialog.FileName)





I1 = PictureBox1.Image




PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click


Dim Cx, Cy, o(256), grn(256), blue(256), red(256) AsInteger


Dim o1(256), r1(256), b1(256), g1(256) AsInteger'For histogram & rect draw box


Dim PHX(1240)


Dim DFR(1280, 1024), DFG(1280, 1024), DFB(1280, 1024), PHV(1600, 1200), HCX(1024) AsString


Dim DFRT(1280, 1024), DFGT(1280, 1024), DFBT(1280, 1024) AsInteger'### added temp color channels


Dim CT As Color ' color object


Dim wow AsBoolean = False


'Dim LMP As Point = MousePosition


Dim I3 As Bitmap


'= New Bitmap(I1.Width, I1.Height)`


' PictureBox1.Image = CropBitmap(I4, PictureBox1.Left, PictureBox1.Top, I4.Width / 2, I4.Height / 2)


'Code for getting percentage of comparing Cy,Cx to I1


' For Cx = 0 To I1.Width - 1


'For Cy = 0 To I1.Height - 1


'I1 = PictureBox1.Image


'CT = I1.GetPixel(20, 20) 'get the pixel data from the bitmap pixel


'PB2.Text = CInt(((Cy + 1) / I1.Height) * 100) & "%"


'DFR(20, 20) = CT.R 'DFR() is string (8-bit)


'PB2.Text = I1.Width


'DFG(Cx, Cy) = CT.G


'PB1.Text = DFG(Cx, Cy)


'DFB(Cx, Cy) = I1.Height


'PB1.Text = DFB(Cx, Cy)


'PB1.Text = (((CInt(Cx) + 1) / I1.Width) * 100) & "%"






'I3(0, 0) = I4


' I3(0, 1) = New Bitmap(I4.Width, I4.Height, 400, Drawing.Imaging.PixelFormat.Format24bppRgb, DFR(20, 20))


'PictureBox1.Image = I3(0, 0)


'PictureBox1.Height = I3(0, 0).Height


'PictureBox1.Width = I3(0, 0).Width


' Dim x, y As Integer


' 'Get color of the pixel


' For x = 1 To I1.Height


'For y = 1 To I1.Width


'Dim B(x, y) As Color


'A(x, y) = CT.R


'B(x, y) = CT


'B(x + 1, y + 1) = B(x, y)












PrivateSub Form1_Load(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesMe.Load





PrivateSub Timer1_Tick_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick


Dim d AsNew Drawing.Bitmap(1, 1)


Dim b As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(d)



New Drawing.Point(MousePosition.X, MousePosition.Y), New Drawing.Point(0, 0), d.Size)


Dim c As Drawing.Color = d.GetPixel(0, 0)

PictureBox1.BackColor = c

PB2.Text = PictureBox1.BackColor.Name




PrivateSub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click





PublicSub GetPixel_Example(ByVal e As PaintEventArgs)


' Create a Bitmap object from an image file.


Dim myBitmap AsNew Bitmap("Grapes.jpg")


' Get the color of a pixel within myBitmap.


Dim pixelColor As Color = myBitmap.GetPixel(50, 50)


' Fill a rectangle with pixelColor.


Dim pixelBrush AsNew SolidBrush(pixelColor)

e.Graphics.FillRectangle(pixelBrush, 0, 0, 100, 100)









a c# class's single dimension byte array contains socket level instrument sensor data as per:

publicstaticbyte[] frameData

whose indexed byte values need to be transferred into a single dimensional integer array which will be the basis for a vb.net graphics control to display the data as per;

Property Int_Clutter_In() AsInteger() 

How would I make this conversion, a byte array copy? (hmm, deep or shallow?)

Thank you!




I want to write an extension method that works with all kinds of arrays (Integer, String, Decimal, ...). It returns an array of the same type and size as the input parameter array.

The following code works:

    <Extension()> _
    Function DoSomething(ByVal arrIn As System.ArrayAs System.Array
        Dim arrOut = arrIn.Clone
        '...processing steps
        Return arrOut
    End Function

However in order to avoid the 2n operations (Clone, Clear) for very large arrays, I tried and failed with the following two attempts:

   <Extension()> _
    Function DoSomethingElse(ByVal arrIn As System.ArrayAs System.Array
        Dim arrOut() As Object 'how do I get the type of the input array?
        ReDim arrOut(arrIn.Length - 1)
        Return arrOut               'doesn't have the same type as input array
    End Function
  <Extension()> _
    Sub DoSomethingElse(ByVal arrIn As System.ArrayByRef arrOut As System.Array)
        ReDim arrOut(arrIn.Length - 1)  'error: Redim requires an arry ?!
        '...processing steps
    End Sub

What is the simplest and fastest way to say "create an empty array of same type and size as the input array" ?

thanks herbert



I am struggling with the function definition which takes arrays from two pointers?Please see the attached code.

Many thanks in advance for help!

/*This program lets the user enter two arrays of ten elements. It then displays the sum of values of two arrays into the third arrays*/
#include <stdio.h>
int x,y, array1[10],array2[10],*ptr1,*ptr2, call;
int sum( int *ptr1, int a, int *ptr2, int b);
int main()
	printf("Enter the 10 elements:\n");
	for (x=0;x<10;x++)

	printf("Enter the second 10 elements:\n");
	for (y=0;y<10;y++)
	printf("the first_array array1 you entered is\n");
	for (x=0;x<10;x++)
	printf("the second_array array2 you entered is\n");
	for (y=0;y<10;y++)
	printf("The added_array is %d",call);
	return 0;

int sum( int *ptr1, int a, int *ptr2, int b)
	int added_array[10];
	return added_array[10];


Hi there. I have a function, callable from C# in an interface looks something like this

 Process( float
[][] data ); 

It is implemented as follows in C++/CLI

void Process( array <array <float >^>^ data ) {
// create array of native pointers for interop
float ** ppData = newfloat *[data->Length];
for ( int i = 0; i < data->Length; ++i ) {
pin_ptr<float > pRow = &data[i][0]
ppData[i] = (float *) pRow
// call native function to process data in-place Native::Process( ppData );
// release memorydelete [] ppData;

However, although this will compile, I am not guaranteed that the GC will not move the managed arrays since the pin_ptr goes out of scope before Native::Process() is called. Since I can't create an array of pin_ptrs, how about

// pin the array
GCHandle ^hData = GCHandle::Alloc( data, GCHandleType::Pinned );
Native::Process( ppData );<br/>

Is this sufficient to pin the entire array, or could the GC still move the constituent data? Is it then necessary to do


<GCHandle^>^ hData = gcnewarray
for ( int i = 0; i < hData->Length; ++i ) {
hData[i] = GCHandle::Alloc( data[i], GCHandleType::Pinned );
Native::Process( ppData );
for ( int i = 0; i < hData->Length; ++i ) {


My intuition leads me to believe it's this second option, but a definitive answer would be great.






Im looking to implement a array containing a array of bool values.  I tryed to use

bool[,][,] CopyArray = newbool[8,8][8,8];
This produced the error "Error    1    Invalid rank specifier: expected ',' or ']' ".  Im not sure what to do about this,  Am i implementing the array wrong?

I have a web service that returns a large amount of data.  When the array size is about 4,000 the web service returns the data just fine.  Bump that up to over 7,000 and the web service just returns an empty array.  Any ideas on what I can change to get it to return all objects?


I need to convert char array to clr::array<char> say,

char a[10] ="hello";

array<char>^ charArray= gcnew array<char>(10);

charArray = a;//somthing like this

Is there any way to make this happen. Please help..... 


                   while converting arraylist to byte array ..it shows an exception called invalid cast exception ..how can i overcome it.and convert arraylist to byte array....in C#..


I'm sure this has been asked more then once, sorry for asking once again.. :(

Visual C++

I have a array<System::Byte> and a array<System::UInt32>..

Is there an easy way to convert a Byte array to a UInt32?

Please understand that I'm not looking for a one to one conversion.... In other words, I don't want each Byte converted into a UInt32..  The Byte array is a multiple of 4 Bytes. So the first 4 Bytes would make the first UInt32..

I'm working with Sockets and some of the data in the returned Byte array is an list of UInt32 values. It would be nice to have a built in .NET method to make pulling this out easier that how I'm doing it now.


I've been scratching my head a bit and am hoping someone could help me split an array up into multiple arrays. 


Say Class1 has a property GroupID and Class2 has a property called ID. 


Class1[] class1;

Class2[] class2;


I need to group all of the elements by GroupID and create a new array for each GroupID found in class1 and pass the GroupID of each element of class1 to the ID property of class2. 


Okay, so, since Web service component of Integration Servies is useless (wonder why its still taking up space in the toolbox) the way to use a webservice is to call it from script task.

My Webservice returns an array of a structure, and i want to store it as a list of array of object, for simplicity.

Therefore i transfer its output into List<object[]> and then i have to somehow store this list. I want to later use a foreach on the variable to get individual objects out.

So i am doing this:

System.Array AoOA = new object[LoOA.Count][];
      int xi = 0;

      foreach (Object[] obj in LoOA)
        AoOA.SetValue(obj, xi);

Dts.Variables["DataTable"].Value = AoOA;

where LoOA is List of Object Array, type List<object[]>

This gives an error of :

Error: 0x1 at Script Task: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.SafeArrayTypeMismatchException: Specified array was not of the expected type.

Removal of the last row (Dts.Variables["DataTable"].Value = AoOA;) removes the error so this is what is causing the problem. declaring the object[][] typed class also does not help.
(DataTable is a read-write variable of type "Object")

Am i doing something wrong here? How should i store arrays with variables in IS?


Dear everybody

I am using vs2008, MFC, Smart Device, dlg,  and I have a structure


struct ctPrmStruct


   wchar_t cityName[47];

   double cityLat;

   double cityLng;


and many arrays of  this structure like :


ctPrmStruct X[2][30], Y[15][20], Z[20][3], ……………….;


I need to use their elements in a loop ( in the first cycle use elements of   X  , in the second cycle elements of   Y , etc.) .

How is it posible (with minimum size of .exe file and minimum memory space) ?

I appreciate a short code or even  hint to help me out.


Thanks in addvance.


private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
            ArrayList colorArray = new ArrayList();
            ArrayList fontArray = new ArrayList();
            colorArray.Add(new SolidBrush(Color.Yellow));
            colorArray.Add(new SolidBrush(Color.Black));
            colorArray.Add(new SolidBrush(Color.Azure));
            colorArray.Add(new SolidBrush(Color.Firebrick));
            colorArray.Add(new SolidBrush(Color.DarkMagenta));

            // Add blank items to the list, since the text we will display
            // will be the name of the Color we are painting

            // Fill an array with the different fonts that you will use to display
            // items in the other comboBox

            fontArray.Add(new Font("Ariel", 15, FontStyle.Bold));
            fontArray.Add(new Font("Courier", 12, FontStyle.Italic));
            fontArray.Add(new Font("Veranda", 14, FontStyle.Bold));
            fontArray.Add(new Font("System", 10, FontStyle.Strikeout));
            fontArray.Add(new Font("Century SchoolBook", 15, FontStyle.Underline));

            // Add the items that in the listBox


            Graphics g = e.Graphics;

            // Get the bounding rectangle of the item currently being painted
            Rectangle r = e.Bounds;
            Font fn = null;

            if (e.Index >= 0)
                // Get the Font object, at the specifid index in the fontArray
                fn = (Font)fontArray[e.Index];

                // Get the text that we wish to display
                string s = (string)comboBox1.Items[e.Index];

                // Set the string format options
                StringFormat sf = new StringFormat();
                sf.Alignment = StringAlignment.Near;

                // Draw the rectangle
                e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Black), 2), r);

                if (e.State == (DrawItemState.NoAccelerator | DrawItemState.NoFocusRect))
                    // if the item is not selected draw it with a different color
                    e.Graphics.FillRectangle(new SolidBrush(Color.White), r);
                    e.Graphics.DrawString(s, fn, new SolidBrush(Color.Black), r, sf);
                    // if the item is selected draw it with a different color
                    e.Graphics.FillRectangle(new SolidBrush(Color.LightBlue), r);
                    e.Graphics.DrawString(s, fn, new SolidBrush(Color.Red), r, sf);



System.OutOfMemoryException was unhandled
  Message="Out of memory."
       at System.Drawing.Graphics.FromHdcInternal(IntPtr hdc)
       at System.Windows.Forms.ComboBox.WmReflectDrawItem(Message& m)
       at System.Windows.Forms.ComboBox.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
       at System.Windows.Forms.Control.WmOwnerDraw(Message& m)
       at System.Windows.Forms.Control.WmDrawItem(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
       at System.Windows.Forms.Control.WmOwnerDraw(Message& m)
       at System.Windows.Forms.Control.WmDrawItem(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ComboBox.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ComboBox.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
       at System.Windows.Forms.ComboBox.DefChildWndProc(Message& m)
       at System.Windows.Forms.ComboBox.ChildWndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)




I can create multi-dimensional (rectangular) arrays with non-zero lower bounds like this:
int[,] i1 = (int[,]) Array.CreateInstance(typeof(int), newint[] { 2,2 }, newint[] { 100,100 });

How can I create a single-dimension array with a non-zero lower bound? The following line of code compiles, but at runtime, the cast fails:
int[] i2 = (int[]) Array.CreateInstance(typeof(int), newint[] { 2 }, newint[] { 100 });


I need to append STRINg to Array and cast it 1-dimensionalArray



Dim remoteFileNames(0) AsString


Dim j AsInteger


For j = 0 To ftpFileNames.GetUpperBound(0)


If InStr(ftpFileNames(j), FileTimeStampNew) > 0 Then

remoteFileNames = Split(Dts.Variables(

"FtpRemoteDirectory").Value) & ftpFileNames(j)





Next j


Here "FtpRemoteDirectory" is a string  and  ftpFileNames() is the Array String which list the FileNames.

and remoteFileNames is 1-dimension array


Please advice how to do this!!!!!


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure