The problem with reading the array

04/01/2009 - 13:13 por Mariusz S. | Informe spam
Hello,

how to read a value from a single plate to be passed in the static
method, for example:

public static Array Tab()
{
string[] dane = new string[3] { "aa", "bb", "cc", "dd" };
return dane;
}

private void Wynik()
{
Array dane = Tab();
test.Text = dane[0]; // Error
}

Mariusz

Preguntas similare

Leer las respuestas

#1 SoftJaén
04/01/2009 - 19:25 | Informe spam
"Mariusz S." wrote

how to read a value from a single plate to be passed in the static method,
for example:

public static Array Tab()
{
string[] dane = new string[3] { "aa", "bb", "cc", "dd" };
return dane;
}

private void Wynik()
{
Array dane = Tab();
test.Text = dane[0]; // Error
}



Hello, Mariusz:

First, to declare and to initialize an Array it is done of the following
way:

public static Array Tab()
{
string[] dane = {"aa", "bb", "cc", "dd"};
return dane;
}

Second, an object «System.Array» cannot be indexed. You have to use the
method «GetValue» of the object «System.Array»:

private void Wynik()
{
Array dane = Tab();
test.Text = dane.GetValue(0).ToString();
}

A greeting

Enrique Martínez
[MS MVP - VB]

Nota informativa: La información contenida en este mensaje, así como el
código fuente incluido en el mismo, se proporciona «COMO ESTÁ», sin
garantías de ninguna clase, y no otorga derecho alguno. Usted asume
cualquier riesgo al poner en práctica, utilizar o ejecutar lo recomendado o
sugerido en el presente mensaje.
Respuesta Responder a este mensaje
#2 Mariusz S.
04/01/2009 - 19:55 | Informe spam
thank you
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida