mirror of
https://bitbucket.org/Mattrixwv/cstutorials.git
synced 2025-12-06 18:34:03 -05:00
Initial commit with a few examples
This commit is contained in:
27
Lists.cs
Normal file
27
Lists.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
//C#/Tutorials/HelloWorld.cs
|
||||
//Matthew Ellison
|
||||
// Created: 07-29-20
|
||||
//Modified: 07-29-20
|
||||
//This shows some basic list operations
|
||||
|
||||
|
||||
using System;
|
||||
|
||||
|
||||
namespace mee{
|
||||
public class Lists{
|
||||
public static Main(string[] args){
|
||||
List<string> names = new List<string> { "Matthew", "Ana", "Felipe", "Maria", "Bill"};
|
||||
names.Remove("Ana");
|
||||
names.Add("Felipe");
|
||||
foreach(string name in names){
|
||||
Console.WriteLine($"{name}");
|
||||
}
|
||||
int location = names.IndexOf("Felipe");
|
||||
Console.WriteLine($"location = {location}");
|
||||
location = names.IndexOf("Bob");
|
||||
Console.WriteLine($"location = {location}");
|
||||
Console.WriteLine($"size = {names.Count}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user