Answer the question
In order to leave comments, you need to log in
C# How to get data out of an array?
Hello! Need help! I can’t deal with arrays, I don’t understand what the problem is and I can’t solve it myself.
The first class file.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplicationStart
{
class Document
{
private string name;
public string NameDoc { get; set; }
public string PageDoc { get; set; }
public string ContentDoc { get; set; }
public string SizeFile { get; set; }
public Document(string name, string page, string content, string size)
{
NameDoc = name;
PageDoc = page;
ContentDoc = content;
SizeFile = size;
}
public Document(string name)
{
this.name = name;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplicationStart
{
public class DocOrganaizer
{
static Document[] SearchToName( string name,Document[] Docs)
{
foreach (string with in SearchToName(name)
Console.WriteLine(c);
}
static Document[] SearchToPagedoc(Document[] Docs, string pagedoc)
{
return Docs;
}
static Document[] SearchToContent(Document[] Docs, string content)
{
return docs;
}
static Document[] SearchToSizefile(Document[] Docs, string sizefile)
{
return Docs;
}
static void Main(string[] args)
{
Document[] Docs =
{
new Document("ccccc","zzzzz","ddddd","aaaaaaa"),
new Document("cc1ccc","zzzz1z","ddddd1 ","aaaaaaa1")
};
while (true)
{
string inputUser = Console.ReadLine();
if (inputUser == "exit") break;
}
}
Answer the question
In order to leave comments, you need to log in
here some remarks and misunderstanding of your decisions will be enough for an abstract. the searchtoname method, promising to search for something, causes a cycle that the hell understand how it is organized and inside itself causes an overload of searcntoname, which is not defined in principle. in fact, this is an attempt to make a cyclic recursion that, apart from stackoverflowexception, does nothing. Further, this method promises to return an array, and does not return anything in principle. Only litters in the console.
The meaning of the problem is not quite clear
. What is the question?
static Document[] SearchToName( string name,Document[] Docs)
{
foreach (string c in SearchToName(name)
Console.WriteLine(c);
}
Here, for example, return is omitted
I need to get data from
Document[] Docs =
{
new Document("ccccc","zzzzz","ddddd","aaaaaaa"),
new Document("cc1ccc","zzzz1z","ddddd1","aaaaaaa1")
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question