I'm trying to add data to 2D array and also assign to declared string (arr) if it's possible using C#. I'm new to C# and struggling already two days with this. Thank you in advance
string[] arr = new string[] {};
static string[,] ErrorList()
{
string[,] errs = {
{"Err1","Text is too long"},
{"Err2","Incorrect characters"},
};
if (FileChecker())
{
// I KNOW THIS IS ERROR BUT HERE I WANT TO ADD THIS LINE IF FILE(S) NOT FOUND
// string[,] errs += {
// {"Err3","Txt file(s) was not found."},
// };
}
// I KNOW THIS IS ERROR BUT I WANT TO ASSIGN errs to arr (declared string)
// TO REACH LATER FROM OTHER CLASSES
// arr = errs;
return errs;
}
public static bool FileChecker()
{
DirectoryInfo d = new DirectoryInfo("template");
FileInfo[] Files = d.GetFiles("*.txt");
foreach (FileInfo file in Files)
{
Console.WriteLine(file.Name);
}
if(Files.Length != 0)
{
return true;
}
return false;
}