fork download
  1. using System.Collections;
  2. using System.Collections.Generic;
  3.  
  4. public class Program {
  5. public static void Main() {
  6. var array = new ArrayList() { 1, "texto" };
  7. var total = 0;
  8. foreach (var item in array) {
  9. //total += item; //se tirar o comentário dá erro quando tentar somar a string
  10. }
  11. //array[1].Contains("t"); //mesmo sendo string não pode acessar Contains() porque o tipo é object
  12. ((string)array[1]).Contains("t");
  13. var list = new List<int>() { 1, /*"texto"); //<-- Error at compile process //ddaria erro aqui*/ };
  14. total = 0;
  15. foreach (var item in list) total += item;
  16. }
  17. }
  18.  
  19. //https://pt.stackoverflow.com/q/227678/101
Success #stdin #stdout 0.01s 14500KB
stdin
Standard input is empty
stdout
Standard output is empty