A
A
Anton Hidden2016-02-12 19:06:35
Database
Anton Hidden, 2016-02-12 19:06:35

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;
}
}
}

Second file Program.
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;
}
}

Thanks to everyone who will respond.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Kovalsky, 2016-02-12
@dmitryKovalskiy

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.

O
Oleg, 2016-02-12
@eleventyseven

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

A
Anton Hidden, 2016-02-12
@antonsk2013

I need to get data from

Document[] Docs =
{
new Document("ccccc","zzzzz","ddddd","aaaaaaa"),
new Document("cc1ccc","zzzz1z","ddddd1","aaaaaaa1")
};

And display them by name or page, etc. (string name, string page, string content, string size)
I see examples but don't understand. (no one can tell)
static void ForEachLoopExample()
{
string[] carTypes = { "Ford" , "BMW", "Yugo", "Honda" };
foreach (string with in carTypes)
Console.WriteLine(c) ;
int[] mylnts = { 10, 20, 30, 40 };
foreach(int i in mylnts)
Console.WriteLine(i);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question