Go on...Stellares said:When I made a GUI interface to track the ip address of a potential murder suspect in visual basic.
Worker.AddWorker(Console.ReadLine());
private static int WorkerCounter;
private static Worker[] WorkerList = new Worker[WorkerCounter];
public static void AddWorker(string input)
{
input = input.Replace(" ", "");
WorkerCounter++;
Array.Resize<Worker>(ref WorkerList, WorkerCounter);
string[] inputstring = input.Split(',');
WorkerList[WorkerCounter] = new Worker(inputstring[0], inputstring[1], Convert.ToInt32(inputstring[2]));
}
Stellares said:When I made a GUI interface to track the ip address of a potential murder suspect in visual basic.
I wouldn't know what exactly is going on in C#, but static methods are class methods. If you don't declare them static, they are usable only by the objects of that class. So it seems that you are mixing some OOP concepts. The catch of OOP comes from creating objects from some class, whereas the object is in itself a data structure (with the structure you defined when you defined the class) with behavior implemented (in form of methods, which should not be static if you are planning to use within objects).Toma said:Okay, several C# questions:
First of all, I was trying to use methods from a class from within my main method, like:
To use this, I had to spam "static" all over my class Worker because it told me the main class cant use any class method that isnt static (even the variables it uses need to be static?).
Is that a problem? Because as it looks right now EVERY method I am going to touch would need to be static, no idea what it actually does but it sounds wrong. This is one method I'd like to use:
Toma said:Any hints on how to "get" OOP? My major problem right now.
Toma said:Okay, several C# questions:
To use this, I had to spam "static" all over my class Worker because it told me the main class cant use any class method that isnt static (even the variables it uses need to be static?).
public void DoStuff() { ... }
public static void DoStuff() { ... }
Toma said:Next question, right now, this code doesnt work because of an IndexOutOfRangeException in the last line. Why is that? The WorkerList is made bigger everytime I use the AddWorker method and the inputstring gets exactly 3 values ("a,b,3"), so they are big enough, right?
And right after I gave the input the program gives me the IOORE.
string[] bob = new string[2];
bob[0] = "a"; // ok
bob[1] = "b"; // ok
bob[2] = "c"; // error, index out of bounds
private static List<Worker> WorkerList = new List<Worker>();
public static void AddWorker(string input)
{
input = input.Replace(" ", "");
string[] inputstring = input.Split(',');
WorkerList.Add(new Worker(inputstring[0], inputstring[1], Convert.ToInt32(inputstring[2])));
}
Mister Zimbu said:Lots of help
Toma said:Okay, several C# questions:
Next question, right now, this code doesnt work because of an IndexOutOfRangeException in the last line. Why is that? The WorkerList is made bigger everytime I use the AddWorker method and the inputstring gets exactly 3 values ("a,b,3"), so they are big enough, right?
And right after I gave the input the program gives me the IOORE.
private static int WorkerCounter;
private static Worker[] WorkerList = new Worker[WorkerCounter];
public static void AddWorker(string input)
{
input = input.Replace(" ", "");
WorkerCounter++;
Array.Resize<Worker>(ref WorkerList, WorkerCounter);
string[] inputstring = input.Split(',');
WorkerList[WorkerCounter] = new Worker(inputstring[0], inputstring[1], Convert.ToInt32(inputstring[2]));
}
public static void AddWorker(string s1, string s2, int i)
{
WorkerCounter++;
WorkerList[WorkerCounter] = new Worker(s1, s2, i);
}
2001/08/19 - DivX ;-) for GBA - Posted by: Jeff Frohwein
Here is Milhouse's port of OpenDivX to the GBA platform. It currently runs at about 1 FPS. Included is an example ROM & GCC src code.
Totalriot said:Stuff
Toma said:Seems like I got even more problems than what I am already aware of. But yeah, you are right. I'll rewrite that and try to get used to doing that.
Totalriot said:No worries, you are definitely on the right track. The most important thing when learning a programming language on your own is to actually try it and then let other people review your code. You seem to do that
Earlier on, you have asked for programming tasks. A good source are university programming exercises. Many university professors have these for their courses online, although you will find more examples for Java than for C#, as Java is a more popular learning language.
Try googeling "exercises c#" or "exercises c# solutions" and see what you'll find. For example this one seems OK but does not offer any solutions: http://www.cs.aau.dk/~bt/JAVA-CSHARP/CSharpExercises.pdf
It obviously like several others missed post 91.Stellares said:When I made a GUI interface to track the ip address of a potential murder suspect in visual basic.
I find it best to consider what in your program you will want to have multiple instances of that you want manipulate separately. Take your dungeon generator as an example: the dungeon itself might be something you want to be able to make multiple instances of (different levels) and give its own properties and methods (size, number of rooms, generating the rooms, treasure and enemies etc.).Toma said:Any hints on how to "get" OOP? My major problem right now.
deadbeef said:Compiler writers do!
Well gibberish into even more gibberish, I guess.
Thought of my other one - writing my own scripting language and interpreter.
The_Technomancer said:This isn't really the thread for it, but if I wanted to get started in simple game design, where should I start? I'm already fairly proficient in C++ and by extension I can hold my own in Java, and I've heard Python is something to look into. Any other tips?
Well I've found I pick up languages fairly quickly, so I'm willing to invest 3 or 4 months into something I don't have experience in if its better for handling game programming. Yeah, I'll definitely check for some books at the library. I've had vague ideas about how to do a turn based strategy game using simple classes, but I have no idea if thats anywhere on the right track or not.SlipperySlope said:I'd say either take a class, or get a getting started game programming book. Since you already know C++, try to get one in that language.
Edit - Perhaps you can get a beginners DirectX book. Game programming is really rewarding, but there are a lot of little nuances you will never even think games had until you start programming them.
I'd say game programming is the funnest of all the programming fields. Which probably explains the pay....
SlipperySlope said:I'd say game programming is the funnest of all the programming fields. Which probably explains the pay....
The_Technomancer said:Well I've found I pick up languages fairly quickly, so I'm willing to invest 3 or 4 months into something I don't have experience in if its better for handling game programming. Yeah, I'll definitely check for some books at the library. I've had vague ideas about how to do a turn based strategy game using simple classes, but I have no idea if thats anywhere on the right track or not.
SlipperySlope said:Some people like to use managed code, but there is a performance issue doing that.
Kalnos said:Will this really matter in a beginner/indie project? Terraria, Magicka, CSTW seem to be doing just fine to me.
Toma said:Any hints on how to "get" OOP? My major problem right now.
iapetus said:What don't you 'get' about it? The basic concepts? How to apply it?
Toma said:Could you explain why "managed" code is even regarded as a problem? Beginner here. I read up a bit about it, but didnt find much.
Ecrofirt said:It doesn't teach you good memory management skills, which generally leads to people being much sloppier programmers.
When you do something like create an object on the heap in C#, and then finish using it, the memory allocated for the object will get removed by the garbage collector eventually. If you were to create an object in C++ and finish using it without manually de-allocating the memory, you'd have a memory leak. C++ is unforgiving when it comes to memory allocation/de-allocation.