Sign in to follow this  

C#, odd problem....

This topic is 4801 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here is my code: using System; using System.IO; public class Mygame { string[] weaponname = new string[10]; int[] weaponpower = new int[10]; int[] weaponend = new int[10]; int[] weaponcost = new int[10]; public static void Main() { ReadWeapons(); } public static void ReadWeapons() { TextReader tr = new StreamReader("w.dat"); int i = tr.Read(); int x = 0; while (x < i) { weaponname(x) = tr.Read(); weaponpower(x) = tr.Read(); weaponend(x) = tr.Read(); weaponcost(x) = tr.Read(); x++; } } } Done... When I try to compile, this is what it says: c:\WINDOWS\Microsoft.NET\Framework\v2.0.40607\mscorlib.dll: error CS0011: Referenced class 'string' has base class or interface '' defined in an assembly that is not referenced. You must add a reference to assebly ''. c:\WINDOWS\Microsoft.NET\Framework\v2.0.40607\mscorlib.dll: error CS0011: Referenced class 'int' has base class or interface '' defined in an assembly that is not referenced. You must add a reference to assebly ''. Any suggestions?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
This compiles in .NET 2003. I created an empty console app and made some changes to your code. I think some of your environment variables may not be set up correctly.

Under options->projects->VC++ their should be some references to $(framework) directories.

Do you have any sample programs that came with your compiler that do compile correctly?

Also, I don't think the TextReader.Read() method is being used correctly. It only returns the next ascii character from the file.

//==========================================
public class Mygame
{
public static char[] weaponname = new char[10];
public static int[] weaponpower = new int[10];
public static int[] weaponend = new int[10];
public static int[] weaponcost = new int[10];

public static void Main()
{
ReadWeapons();
}

public static void ReadWeapons()
{
TextReader tr = new StreamReader("w.dat");
int i = tr.Read();
int x = 0;
while (x < i)
{
weaponname[x] = (char) tr.Read();
weaponpower[x] = tr.Read();
weaponend[x] = tr.Read();
weaponcost[x] = tr.Read();
x++;
}
}
}
}

Share this post


Link to post
Share on other sites
thanks for your replies, guys : ).... i dunno what was wrong
my comp got a virus earlier this week that screwed up windows, so i had to format my hd :(.... But now when i compile my code, it works. BTW, thanks about that textreader.read part : )

Share this post


Link to post
Share on other sites

This topic is 4801 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this