This C# program demonstrates how to fill a list with an array of elements.
using System; using System.Collections.Generic; namespace XoaX { class Program { static void Main(string[] args) { string[] saGiftsOfTheHolySpirit = new string[] { "Wisdom", "Understanding", "Counsel", "Fortitude", "Knowledge", "Piety", "Fear of the Lord" }; List<string> qGiftsOfTheHolySpirit = new List<string>(saGiftsOfTheHolySpirit); Console.WriteLine("Gifts of the Holy Spirit:"); Console.WriteLine("-------------------------"); foreach (string sGift in qGiftsOfTheHolySpirit) { Console.WriteLine(sGift); } Console.WriteLine(""); } } }
Gifts of the Holy Spirit: ------------------------- Wisdom Understanding Counsel Fortitude Knowledge Piety Fear of the Lord Press any key to continue . . .
© 20072024 XoaX.net LLC. All rights reserved.