TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Michael Jacquet
NA
7
1.1k
The first character of my String is printing "?"
May 2 2014 4:57 PM
Hello,
I am new to programming and I have a strange issue.
I read lines from a textfile and throw theim separetly in an String Array.
Everything is working fine except that when I WriteLine(Array[0]) it writes in the console:
?My sentence bla bla bla....
All others element of the array write just fine...
Another odd thing is that when I use the imediate window to ask about that element, it writes it just fine.
Here is the code... If someone can figure out my mistake, it would be awesome.
Thank you!
(I didn't find a way to show the code properly so I hope it s readable)
namespace Radio
{
class Program
{
static void Main(string[] args)
{
StreamReader myReader = new StreamReader(@"playlist.txt");
String line = "";
int compteur = 0;
Console.WriteLine("Ordre normal :");
while(line != null)
{
line = myReader.ReadLine();
if(line!=null)
{
Console.WriteLine(line);
compteur++;
}
}
Console.WriteLine("Nombre de chansons dans la playlist:" + compteur.ToString());
String[] ordreNorm = new string[compteur];
myReader.BaseStream.Position = 0;
for (int i = 0; i < compteur; i++)
{
ordreNorm[i] = myReader.ReadLine();
}
foreach (string song in ordreNorm)
{
Console.WriteLine(song);
}
Console.WriteLine(ordreNorm[0]);
Console.ReadLine();
}
}
}
Reply
Answers (
7
)
deleting rows from Datatable causes error
sql queries in codesmith generator