I have a string array and I need to use the first string in a string array that is not null. Let's look at this piece of code -
string[] strDesc = new string[] {"", "", "test"}; foreach (var Desc in strDesc) { if (!string.IsNullOrEmpty(Desc)) { txtbox.Text = Desc; break; } }
So, according to this snippet of code, txtbox should now display "test" .
For this, I have this code. This is working fine. But, I want to know if LINQ can be used to get the same result, and perhaps skipped with an extra foreach loop?
source share