From 88d67173b0cc0d0e850c66378812b8f038d5b427 Mon Sep 17 00:00:00 2001 From: Rashed Hassan Date: Tue, 8 Nov 2022 21:19:26 +0600 Subject: [PATCH] Added CSharp solution for 58 - Length of Last word problem. --- csharp/58-Length-of-Last-Word.cs | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 csharp/58-Length-of-Last-Word.cs diff --git a/csharp/58-Length-of-Last-Word.cs b/csharp/58-Length-of-Last-Word.cs new file mode 100644 index 000000000..2db7808e3 --- /dev/null +++ b/csharp/58-Length-of-Last-Word.cs @@ -0,0 +1,8 @@ +public class Solution { + public int LengthOfLastWord(string s) { + s = s.TrimEnd(); + string[] arr = s.Split(' '); + return arr[arr.Length - 1].Length; + } +} +