|
||||||
| C# Programming C# (pronounced C-sharp) is a new object oriented language from Microsoft and is derived from C and C++. It also borrows a lot of concepts from Java too including garbage collection. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Hello,
I am trying to write a program for a class that I am taking and I am having a little trouble with assigning values to an array. Here is the entirety of my code the highlighted area is where I am having the problem: Code:
#region Using Directories
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
#endregion
namespace Programming_Project_Text_Query
{
public class Program
{
static void Main()
{
string fileName;
Console.WriteLine("Insert the text file name.");
fileName = Console.ReadLine();
try
{
StreamReader checkFile = new StreamReader(fileName);
Concordance newIndex = new Concordance(fileName);
}
catch (FileNotFoundException)
{
Console.WriteLine("File not found, please try again.");
Console.WriteLine("\n");
Main();
}
}
}
public class Concordance//: IDictionary
{
public static StreamReader file;
public Concordance(string f)
{
Dictionary<string, int[]> Concordance = new Dictionary<string, int[]>();
FileInfo newFile = new FileInfo(f);
file = newFile.OpenText();
string[][] fileByWord = new string[findNumberOfLines()][];
int L = 0;
using (StreamReader file2 = newFile.OpenText())
{
string line = "";
while ((line = file2.ReadLine()) != null)
{
Console.WriteLine(line);
string[] tempArray = new string[(line.Split(' ')).Length];
tempArray = line.Split(' ');
int arrayLength = tempArray.Length;
for (int W = 0; W < tempArray.Length; W++)
{
fileByWord[L][W] = tempArray[W];
}
L++;
}
}
}
#region findNumberOfLines() Method
public static int findNumberOfLines()
{
int i = 0;
string line = file.ReadLine();
while (line != null)
{
i++;
line = file.ReadLine();
}
return i;
}
#endregion
}
}
Thanks Last edited by peage1475; 04-24-2008 at 02:23 PM. |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Array manipulation Question in C++ | JJJIrish05 | C and C++ | 1 | 03-08-2008 02:06 PM |
| Help regarding the sorting of arrays with flags! | Yuriy M | C and C++ | 3 | 10-12-2007 10:30 PM |
| Usage of array structures to increment letter instances of text | Yuriy M | C and C++ | 2 | 09-13-2007 10:49 AM |
| fread into array position | kenna | C and C++ | 0 | 08-17-2007 08:03 AM |
| Python 2D array question | annannienann | Python | 3 | 04-23-2007 04:36 PM |