/*
autor: Fer Carraro
fecha: 11/04/2015
descripción: Se define una cadena tipo string y se recorre cada caracter mediante un for, los caracteres se agregan a una lista.
*/
using System;
using System.Collections.Generic;
public class Test{
public static void Main(string[] args){
List<string> letras = new List<string>();
for(int s=0; s < str.Length; s++){
char c= str[s];
Console.WriteLine(c);
string cad=c.ToString();
letras.Add(cad);
}
Console.WriteLine(String.Join(",", letras.ToArray()));
}
}
1 Response
using System;
using System.Collections.Generic;
public class Principal{
public static void Main(string[] args){
List<string> letras = new List<string>();
string str = "Fernando";
for(int s=0; s < str.Length; s++){
char c= str[s];
Console.WriteLine(c);
string cad=c.ToString();
letras.Add(cad);
}
Console.WriteLine(String.Join(",", letras.ToArray()));
}
}
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.