-3

I want to extract Guid from this below string array and want output like this:

Output:Log.txt,Logging.txt

string[] str = new string[] { "1250a2d5-cd40-4bcc-a979-9d6f2cd62b9fLog.txt", "bdb31966-e3c4-4344-b02c-305c0eb0fa0aLogging.txt" }; //file name are Log.txt and Logging.txt
List<string> list= new List<string>();
foreach (var item in str)
{
    if (!string.IsNullOrEmpty(item))
    {
        list.Add();  // here i want to store Log.txt and Logging.txt
    }
}

How to do this??

jhmt
  • 1,401
  • 1
  • 11
  • 15
I Love Stackoverflow
  • 6,738
  • 20
  • 97
  • 216

1 Answers1

2
var str = new string[] { "1250a2d5-cd40-4bcc-a979-9d6f2cd62b9fLog.txt", "bdb31966-e3c4-4344-b02c-305c0eb0fa0aLogging.txt" }; //file name are Log.txt and Logging.txt

var arr = str.Select(s=>s.Substring(36)).Where(s=>s.Any()).ToArray();

You can see it in action here: https://dotnetfiddle.net/eHy6Fo

Blindy
  • 65,249
  • 10
  • 91
  • 131