using System;
using System.Text.RegularExpressions;
namespace ArrayDaniel
{
class AgregarNombres
{
public void agrNombres()
{
int cant = 0;
while(true)
{
Console.SetCursorPosition(02,02);
Console.Write("Ingrese la cantidad de personas(máximo 10)...:");
if(Int32.TryParse(Console.ReadLine(), out cant))
{
if (cant > 0 && cant < 11) { break; }
}
}
Regex reg = new Regex("^[A-Za-z ]+$");
byte _top = 4;
string[] nombres = new string[cant];
for(int i = 0; i<cant; i++)
{
while(true)
{
Console.SetCursorPosition(02, _top);
Console.Write("Ingrese nombre....:");
string linea = Console.ReadLine();
if (!string.IsNullOrEmpty(linea) && reg.IsMatch(linea))
{
nombres[i] = linea;
break;
}
}
_top += 2;
}
Array.Sort(nombres);
_top += 2;
Console.SetCursorPosition(02,_top);
Console.Write(" ----- Se muestran los nombres ordenados ----- ");
_top += 2;
int a = 0;
foreach(String i in nombres)
{
Console.SetCursorPosition(02, _top);
Console.Write("Código...: Nombres...:{0}", nombres[a]);
a++;
_top ++;
}
}
}
}
Espero puedan ayudarme realmente estoy estancado.-ahora bien en tu código tu variable miVaSt no es un vector, sólo es un objeto de tipo string, para ser un vector tendría que ser declarado así:No me referia a