Hi kavithav,
Refer below sample code.
C#
string existFile = "";
string[] arr1 = { "Chrysanthemum.jpg", "Desert.jpg", "Hydrangeas.jpg", "Lighthouse.jpg" };
string[] arr2 = { "Hydrangeas.jpg", "Jellyfish.jpg" };
string[] arr3 = { "Koala.jpg", "Lighthouse.jpg" };
string[] arr4 = { "Penguins.jpg", "Tulips.jpg", "Chrysanthemum.jpg", };
for (int i = 0; i < arr1.Length; i++)
{
for (int j = 0; j < arr2.Length; j++)
{
if (arr2[j].ToUpper() == arr1[i].ToUpper())
{
existFile += arr1[i] + ", ";
}
}
for (int j = 0; j < arr3.Length; j++)
{
if (arr3[j].ToUpper() == arr1[i].ToUpper())
{
existFile += arr1[i] + ", ";
}
}
for (int j = 0; j < arr4.Length; j++)
{
if (arr4[j].ToUpper() == arr1[i].ToUpper())
{
existFile += arr1[i] + ", ";
}
}
}
existFile = existFile.Remove(existFile.Length - 2, 2);
Response.Write(existFile);
VB.Net
Dim existFile As String = ""
Dim arr1 As String() = {"Chrysanthemum.jpg", "Desert.jpg", "Hydrangeas.jpg", "Lighthouse.jpg"}
Dim arr2 As String() = {"Hydrangeas.jpg", "Jellyfish.jpg"}
Dim arr3 As String() = {"Koala.jpg", "Lighthouse.jpg"}
Dim arr4 As String() = {"Penguins.jpg", "Tulips.jpg", "Chrysanthemum.jpg"}
For i As Integer = 0 To arr1.Length - 1
For j As Integer = 0 To arr2.Length - 1
If arr2(j).ToUpper() = arr1(i).ToUpper() Then
existFile += arr1(i) + ", "
End If
Next
For j As Integer = 0 To arr3.Length - 1
If arr3(j).ToUpper() = arr1(i).ToUpper() Then
existFile += arr1(i) + ", "
End If
Next
For j As Integer = 0 To arr4.Length - 1
If arr4(j).ToUpper() = arr1(i).ToUpper() Then
existFile += arr1(i) + ", "
End If
Next
Next
existFile = existFile.Remove(existFile.Length - 2, 2)
Response.Write(existFile)
Output
Chrysanthemum.jpg, Hydrangeas.jpg, Lighthouse.jpg