A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by rzuckerm
Welcome to the Longest Word in C# page! Here, you'll find the source code for this program as well as a description of how the program works.
if (args is not [var sentence] || string.IsNullOrWhiteSpace(sentence))
return Usage();
int max = 0,
cur = 0;
foreach (char c in sentence)
{
if (char.IsWhiteSpace(c))
{
cur = 0;
continue;
}
cur++;
max = Math.Max(cur, max);
}
Console.WriteLine(max);
return 0;
static int Usage()
{
Console.Error.WriteLine("Usage: please provide a string");
return 1;
}
Longest Word in C# was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.