Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created September 13, 2020 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/971e20e3e6e3b10fb923536d104af4b1 to your computer and use it in GitHub Desktop.
Save codecademydev/971e20e3e6e3b10fb923536d104af4b1 to your computer and use it in GitHub Desktop.
Codecademy export
using System;
namespace NameGrab
{
class Program
{
static void Main(string[] args)
{
// User Name
string name = "Farhad Hesam Abbasi";
// Get first letter
int charPosition = name.IndexOf("F");
char firstLetter = name[charPositon];
// Get last name
int lastNamePosition = name.IndexOf("Abbasi");
string lastName = name.Substring(lastNamePosition);
// Print results
Console.WriteLine($"{firstLetter}, {lastName}");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment