Need help converting java object program to c# object
Page 1 of 1
KillerCrocker




Posts: 20503

PostPosted: Sat, 14th Jan 2012 16:33    Post subject: Need help converting java object program to c# object
hi guys I have an old program which i wrote year ago in Java object.
Its a simple stuff with couple of classes etc.

now we have C# object classes and i want to convert this into c#. since its almost the same code.
But I am still having some problems with it. errors are:

Error 1 Property or indexer 'Maszyna.nazwa' cannot be assigned to -- it is read only

Error 10 Member 'Pojazd.maxLiczbaPojazdow' cannot be accessed with an instance reference; qualify it with a type name instead

here is that java program in bluej. it compiles Razz
https://rapidshare.com/files/1381488360/java01.rar


3080 | ps5 pro

Sin317-"im 31 years old and still surprised at how much shit comes out of my ass actually ..."
SteamDRM-"Call of Duty is the symbol of the true perfection in every aspect. Call of Duty games are like Mozart's/Beethoven's symphonies"
deadpoetic-"are you new to the cyberspace?"
Back to top
KillerCrocker




Posts: 20503

PostPosted: Sat, 14th Jan 2012 19:52    Post subject:
Ok Ive rewrited it for C# and corrected all the errors I could somehow. There is only 1 error left in the main class.

"The type or namespace name 'NullPointerException' could not be found (are you missing a using directive or an assembly reference?)"

it is referring to this line of code. It is at the end

" try
{
for (int i = 0; i < maszyny.Length; i++)
{
maszyny[i].wyswietl();
}
}
catch (NullPointerException e)
{
}"
[/u]

I have no idea what to input there. Google doesnt help. Finally doesnt help. NOTHING. its c#


3080 | ps5 pro

Sin317-"im 31 years old and still surprised at how much shit comes out of my ass actually ..."
SteamDRM-"Call of Duty is the symbol of the true perfection in every aspect. Call of Duty games are like Mozart's/Beethoven's symphonies"
deadpoetic-"are you new to the cyberspace?"
Back to top
Werelds
Special Little Man



Posts: 15098
Location: 0100111001001100
PostPosted: Sat, 14th Jan 2012 19:58    Post subject:
NullReferenceException would be the one in C# I think, assuming the Java one is what I think it is.
Back to top
KillerCrocker




Posts: 20503

PostPosted: Sat, 14th Jan 2012 20:06    Post subject:
nope. Same error
NullPointerException is the java command


3080 | ps5 pro

Sin317-"im 31 years old and still surprised at how much shit comes out of my ass actually ..."
SteamDRM-"Call of Duty is the symbol of the true perfection in every aspect. Call of Duty games are like Mozart's/Beethoven's symphonies"
deadpoetic-"are you new to the cyberspace?"
Back to top
me7




Posts: 3945

PostPosted: Sat, 14th Jan 2012 20:31    Post subject:
How about:

catch(System.NullReferenceException e)

Also try to clean and rebuild the project. Could be that some precompiled code is messed up.


Last edited by me7 on Sat, 14th Jan 2012 20:32; edited 1 time in total
Back to top
Werelds
Special Little Man



Posts: 15098
Location: 0100111001001100
PostPosted: Sat, 14th Jan 2012 20:31    Post subject:
http://lmgtfy.com/?q=NullPointerException+in+C%23

According to that, the C# equivalent of NullPointerException is the one I posted above. So just importing and using that should be enough.
Back to top
KillerCrocker




Posts: 20503

PostPosted: Sat, 14th Jan 2012 20:31    Post subject:
fixed it (i think) it should be:

catch (NullReferenceException e)
{
Console.WriteLine("{0} Caught exception #1.", e);
}


tho program is doing only half of its task and then stops without error. it works good in java tho...


3080 | ps5 pro

Sin317-"im 31 years old and still surprised at how much shit comes out of my ass actually ..."
SteamDRM-"Call of Duty is the symbol of the true perfection in every aspect. Call of Duty games are like Mozart's/Beethoven's symphonies"
deadpoetic-"are you new to the cyberspace?"
Back to top
Werelds
Special Little Man



Posts: 15098
Location: 0100111001001100
PostPosted: Sat, 14th Jan 2012 20:37    Post subject:
That's exactly what both me7 and I said?
Back to top
KillerCrocker




Posts: 20503

PostPosted: Sat, 14th Jan 2012 20:46    Post subject:
yeah... Ive tried it for an hour. It didnt wanted to work and suddenly fucking visual 2010 accepted it Laughing

but its not throwing exceptions anyway.... it makes one part of the task and in other not.
White window is how it should properly look (tho that boolean shit false/true is not working)

And black window is offcourse vs2010. You don't need to know whats in there to see that it doesnt work completly. i dont know why at all.







Crying or Very sad Crying or Very sad Crying or Very sad


3080 | ps5 pro

Sin317-"im 31 years old and still surprised at how much shit comes out of my ass actually ..."
SteamDRM-"Call of Duty is the symbol of the true perfection in every aspect. Call of Duty games are like Mozart's/Beethoven's symphonies"
deadpoetic-"are you new to the cyberspace?"
Back to top
KillerCrocker




Posts: 20503

PostPosted: Sat, 14th Jan 2012 21:25    Post subject:
hm.... it works when I remove if .... wtf:lol: it shouldnt work without if.
Anyway.

Someone knows any good commands for Write line to make this look better?



3080 | ps5 pro

Sin317-"im 31 years old and still surprised at how much shit comes out of my ass actually ..."
SteamDRM-"Call of Duty is the symbol of the true perfection in every aspect. Call of Duty games are like Mozart's/Beethoven's symphonies"
deadpoetic-"are you new to the cyberspace?"
Back to top
Page 1 of 1 All times are GMT + 1 Hour
NFOHump.com Forum Index - The Useless Void
Signature/Avatar nuking: none (can be changed in your profile)  


Display posts from previous:   

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.8 © 2001, 2002 phpBB Group