Click here to Skip to main content
15,886,963 members
Home / Discussions / C#
   

C#

 
QuestionConvert string to boolean Pin
teejayem27-Apr-06 15:03
teejayem27-Apr-06 15:03 
AnswerRe: Convert string to boolean Pin
Sean8927-Apr-06 15:24
Sean8927-Apr-06 15:24 
GeneralRe: Convert string to boolean Pin
teejayem27-Apr-06 15:35
teejayem27-Apr-06 15:35 
GeneralRe: Convert string to boolean Pin
Sean8928-Apr-06 7:39
Sean8928-Apr-06 7:39 
AnswerRe: Convert string to boolean Pin
Graham Nimbley27-Apr-06 15:25
Graham Nimbley27-Apr-06 15:25 
GeneralRe: Convert string to boolean Pin
Sean8927-Apr-06 15:32
Sean8927-Apr-06 15:32 
AnswerRe: Convert string to boolean Pin
DougW4830-Apr-06 9:40
DougW4830-Apr-06 9:40 
QuestionProblem with System.IO, Please Help Pin
Shadow Sprite27-Apr-06 14:18
Shadow Sprite27-Apr-06 14:18 
My list is not being written to the outFile and I can't seem to figure out why. I will post the code but I am not sure how to paste it correctly. Any Help would be appreciated.

using System;
using System.IO;

namespace Seating_Chart
/*Write a C# program that will read a list of student
* names from a text fileand assemble a seating chart
* onscreen.When the program is first run it should
* display an empty seating grid.Then you should be
* able to change the seating of any student. Such
* as Row 1, Seat 4 and change it's name to "John Doe".
* Any changes made should be immediatley written to
* the file.You must use more than one class. */
{
class Students
{
static void Main ()

{
string [,] Students = new string [5,10];
char answer = ' ';
int row = 0;
int seat = 0;

SeatChange NewSeatChange = new SeatChange();

StreamReader inStream = null;
StreamWriter outStream = null;

FileInfo inFile = new FileInfo (@"Student Seating Chart.txt");
FileInfo outFile = new FileInfo (@"Student Seating Chart.txt");

inStream = inFile.OpenText();

for (int x = 0; x < 5; x++)
{
for (int y = 0; y < 10; y++)
{
Students [x, y]=inStream.ReadLine();
}
}
inStream.Close();

for (int x = 0; x < 5; x++)
{
Students [x, 0]=Convert.ToString(x);
}
for (int y = 0; y < 10; y++)
{
Students [0, y]=Convert.ToString(y);
}

Console.WriteLine ("Seat 1 2 3 4 5 6 7 8 9 10");
Console.WriteLine (" ----------------------------------------");

for (int x = 0; x < 5; x++)
{
Console.Write ("ROW " + (x + 1) + " ");
for (int y = 0; y < 10; y++)
{
Console.Write (" ", Students[x,y]);
}
Console.WriteLine ();
Console.WriteLine();
}
do
{
outStream = outFile.CreateText();
Console.WriteLine("Please enter the Row Number of the student you wish to move: ");
row = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Please enter the Seat number of the student you want to move;");
seat = Convert.ToInt32(Console.ReadLine());

Students = NewSeatChange.Change(Students,seat,row);

for (int x = 0; x < 5; x++)
{
for (int y = 0; y < 10; y++)
{
outStream.WriteLine(Students [x, y]);
}
}
outStream.Close();

Console.WriteLine ("seat 1 2 3 4 5 6 7 8 9 10");
Console.WriteLine (" ----------------------------------------");

for (int x = 0; x < 5; x++)
{
Console.Write ("ROW " + (x + 1) + " ");

for (int y = 0; y < 10; y++)
{
Console.Write (" ", Students[x,y]);
}
Console.WriteLine ();
Console.WriteLine();
}
Console.WriteLine("Would you like to move another student?");
answer = Convert.ToChar(Console.ReadLine());
}while(answer == 'y');
}
}
class SeatChange
{
public string [ , ] Change(string[ , ] Students, int a, int b)
{
Console.WriteLine("Please enter the students name:");
Students[a,b] = Console.ReadLine();
return Students;
}
}
}

Sorry this is so messy.

Shadow Sprite
AnswerRe: Problem with System.IO, Please Help Pin
S. Senthil Kumar27-Apr-06 16:26
S. Senthil Kumar27-Apr-06 16:26 
GeneralRe: Problem with System.IO, Please Help Pin
Shadow Sprite27-Apr-06 23:59
Shadow Sprite27-Apr-06 23:59 
QuestionHow to stop Backgroundworker ? Pin
ALQallaf27-Apr-06 12:50
ALQallaf27-Apr-06 12:50 
AnswerRe: How to stop Backgroundworker ? Pin
Josh Smith27-Apr-06 13:07
Josh Smith27-Apr-06 13:07 
QuestionDrawReversibleFrame? Pin
melanieab27-Apr-06 10:08
melanieab27-Apr-06 10:08 
AnswerRe: DrawReversibleFrame? Pin
Guffa27-Apr-06 10:23
Guffa27-Apr-06 10:23 
GeneralRe: DrawReversibleFrame? Pin
melanieab27-Apr-06 11:08
melanieab27-Apr-06 11:08 
AnswerRe: DrawReversibleFrame? Pin
Guffa27-Apr-06 14:07
Guffa27-Apr-06 14:07 
GeneralRe: DrawReversibleFrame? Pin
melanieab28-Apr-06 9:57
melanieab28-Apr-06 9:57 
QuestionTips for writing a Web Service in C# which will be used by a Java app... Pin
Josh Smith27-Apr-06 9:49
Josh Smith27-Apr-06 9:49 
QuestionThe correct way to dispose of objects Pin
Mark0627-Apr-06 9:32
Mark0627-Apr-06 9:32 
AnswerRe: The correct way to dispose of objects Pin
Colin Angus Mackay27-Apr-06 10:00
Colin Angus Mackay27-Apr-06 10:00 
QuestionRichTextBox tables Pin
Authorof2227-Apr-06 9:24
Authorof2227-Apr-06 9:24 
QuestionWriting Web Control Library Pin
thompson_3827-Apr-06 8:50
thompson_3827-Apr-06 8:50 
AnswerRe: Writing Web Control Library Pin
Josh Smith27-Apr-06 13:03
Josh Smith27-Apr-06 13:03 
Questionexpander control Pin
awu2527-Apr-06 8:25
awu2527-Apr-06 8:25 
AnswerRe: expander control Pin
Ravi Bhavnani27-Apr-06 8:37
professionalRavi Bhavnani27-Apr-06 8:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.