Skip to content

Instantly share code, notes, and snippets.

@sin2akshay
Last active May 10, 2018 06:23
Show Gist options
  • Save sin2akshay/17ea0e52fc529150fb90d478ef48b3fd to your computer and use it in GitHub Desktop.
Save sin2akshay/17ea0e52fc529150fb90d478ef48b3fd to your computer and use it in GitHub Desktop.
Code to understand using System.Collections.ObjectModel.Collection<T> Class
using System;
using System.Linq;
using System.Collections;
using System.Collections.ObjectModel;
class MainClass {
public static void Main (string[] args) {
Console.WriteLine ("Hello World");
Collection<int> intCollection = new Collection<int>();
intCollection.Add(1);
intCollection.Add(2);
intCollection.Add(3);
intCollection.Add(4);
foreach(int num in intCollection)
{
Console.WriteLine(num);
}
//Spreading the ints in a comma separated string
string intColl2str = string.Join(",", intCollection.ToArray());
Console.WriteLine(intColl2str);
Console.WriteLine("END");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment