Mainly for merthsoft to answer, since he uses it for work, and he's pushing me in this direction.

Basically, once I write out the code that the tutorial ( http://www.csharp-station.com/Tutorial.aspx ) gives me, how do I use VS C# to turn this into an executable program to see what it is supposed to do? The tutorial doesn't cover VS, hence my asking.
Once you build it (build > Build Solution), there should be binaries generated somewhere. When can (Debug > start debugging) or (Debug > start without debugging), it is just running the program directly from where-ever it is (I'm not sure where this is by default, because the projects I work on have been around a long time, and I'm betting it's customized; but perhaps you could look for a folder called "output", "debug", or "bin"). ... My new job uses a lot of C# and JavaScript (ASP.NET stuff) Smile
Awesome. I'll look into that at some point this week.

My primary objective is to create an invoicing system more directed at automotive repair shops, because the ones available just really suck. Being in the field myself, I can create a setup that will work wonderfully, I just have to learn C# to be able to do it. :p
So to add what Shkaboinka said, I tend to prefer keyboard shortcuts. Ctrl+Shift+B will build the solution, and F5 will start it with debugging (which is in general how you want to start it). If you want to look at your executable, make sure the project has been saved (when you start a brand new one, it will sometimes not be there yet, express can be silly, so make sure you fully save the project), and it should be in <folder where project is>/bin/Debug.

Also, I was going to make this offer at some point so might as well now: if you ever want any sample code (like, the tutorial isn't explaining well or something), I'd be happy to write and package something for you to look at, just let me know. (P.S. Offer is for tifreak only! Get it while supplies last.)
If anyone is interested in adding C# support to any other IDE they like to use (or if you want to build C# without an IDE at all) you can use this to see how to interface MSBuild, a program that comes with all versions of the .NET Framework: http://msdn.microsoft.com/en-us/library/vstudio/0k6kkbsd.aspx

EDIT: And here's how to work with the C# compiler directly (also in the same folder as MSBuild):
http://msdn.microsoft.com/en-us/library/78f4aasd.aspx
It's a little more difficult to work with, but you don't need a project file, which is especially useful if you only have one C# source that you're using.
These are very helpful things. I think in tifreak's case, since he's fairly new to all this, he should just focus on using VS, though. Learning a language can be hard enough, no need to complicate it too much.
Okay, so last night it was determined that my problems were 1) was using console app code in the window form app section, since the tutorial was not specific and 2) I didn't know what I was doing. :p

However, with the help of the ever so awesome merthsoft, I have successfully gotten a window console to pop up and say hi! So hooray for that.

I think the next section it talked about was getting input from a command line interface. Hopefully I won't get too distracted to work on that tonight.
Honestly you might as well go straight to a GUI app with WinForms or WPF - both are pretty straightforward especially as both have pretty solid UI tools, and you won't be writing a console app anyway so why bother?
Kllrnohj wrote:
Honestly you might as well go straight to a GUI app with WinForms or WPF - both are pretty straightforward especially as both have pretty solid UI tools, and you won't be writing a console app anyway so why bother?

I'd have to disagree with that. Sure, he will most likely never write a console app again once he starts using GUI, but the console is a great way to get used to the language since there's very little overhead you need to worry about - while a GUI program in WPF looks far different than a GUI program in Win32, console programs in two vastly different languages look more or less the same. For instance, I have been writing code and GUI interfaces for years, and yet I deliberately made my first experience with C++ the console interface so that I wouldn't be freaked out by all the new APIs I had to learn.
It doesn't really matter, and it's all going to come down to opinion. If you guys want to debate that, I suggest starting a topic to do so. Let's leave this topic for tifreak's questions and answers, not tangential arguments.
Thanks merth.

So, I've managed to get through lesson 2 finally. Learned me some things about the different types of arrays (though I'm going to have to write some programs up soonish (pending how the next few lessons go and what I glean from them)) to where I put some of this to use to create some form of interactive program.

Edit:

Oh yeah, I do have a question, something that isn't being explained very well..


Code:
 bool[][] myBools = new bool[2][];
        myBools[0] = new bool[2];
        myBools[1] = new bool[1];


All that it says about it is:

Quote:
Next is a jagged array, myBools. It is essentially an array of arrays. We needed to use the new operator to instantiate the size of the primary array and then use the new operator again for each sub-array.


Can someone please explain to me the what/why/etc? Like, why is it new bool [2][], and the second [] is empty? how does lines 2 and 3 work?

I kind of need to be able to see what the computer sees when this all goes down, that way I can understand the commands far better. Any help with a better explanation of this would be greatly appreciated!
Sure, I can help. I'll edit this post quickly, but just want to get in there so's to mitigate duplicated effort Smile

So, to give you an idea of what this looks like without delving too much into it right away, check out this:

Code:
> bool[][] myBools = new bool[2][];
  myBools[0] = new bool[2];
  myBools[1] = new bool[1];
> myBools
bool[2][] { bool[2] { false, false }, bool[1] { false } }
>


So, myBools is an array. Each element in the array is also an array.

bool[][] myBools = new bool[2][];
This creates a new array with two elements in it. Each of those elements is an array of booleans.

myBools[0] = new bool[2];
This is saying the zeroth element is an array of two bools.

myBools[1] = new bool[1];
This is saying the first element is an array of one bool.

Putting it all together we have:
bool[2][] { bool[2] { false, false }, bool[1] { false } }
An array of boolean arrays. In which the first element is an array of 2 booleans, and the second is an array of one boolean.

This concept is called a "jagged array" because if you were to put it out like a Matrix in BASIC it would look like (using 0 instead of false):

0, 0
0

Which is jagged. A bigger example could be:


Code:
> myBools = new bool[5][];
> myBools[0] = new bool[2];
> myBools[1] = new bool[4];
> myBools[2] = new bool[1];
> myBools[3] = new bool[6];
> myBools[4] = new bool[4];
> myBools
bool[5][] { bool[2] { false, false }, bool[4] { false, false, false, false }, bool[1] { false }, bool[6] { false, false, false, false, false, false }, bool[4] { false, false, false, false } }


Which looks like:
0, 0
0, 0, 0, 0
0
0, 0, 0, 0, 0, 0
0, 0, 0, 0

Does that help?
Yes, yes it does. Thakns for clarifying this. Smile

Edit:

it's 'new bool[2][]'

What is the empty [] indicate?
That indicates that it's an array inside the array. If you just had "new bool" that would be a new boolean (you can't do this). "new bool[2]" is an array. "new bool[2][]" is an array of arrays. "new bool[2][2][]" would be an array of arrays of arrays and so on.
You also have the option of omitting the sizes or providing just the sizes. These examples have them combined, which might be confusing as to why you see "[2][]". As an example, consider an array of int:

Code:
int[] array1, array2, array3; // All are arrays of int
array1 = new int[] { 1,2,3 }; // No size needed, as it is clearly 3
array2 = new int[3]; // Allocate an array of 3 ints (no values assigned)
array3 = new int[3] { 1,2,3 }; // ...But you CAN do both

I think in the case of array2, the default value of 0 is given for each of the "3" ints in the new array. Now, let's replace "int" with "int[]", so that we have an array of int-arrays (and we can use the arrays from before as values in these arrays):

Code:
int[][] a1, a2, a3, a4;
a1 = new int[][] { array1, array2, arra3 }; // each element is an int[]
a2 = new int[3][]; // Allocates a new array of 3 int[] values.
a3 = new int[3][] { array1, array2, array3 }; // as before.
a4 = new int[3][4]; // This is a shorthand for doing this:
// a4 = new int[][] { new int[4], new int[4], new int[4] };

One important thing to note is that array variables are stored as references (pointers). That is, when you create a "new" array, memory is allocated, and you get the ADDRESS of that array in memory, and that address is stored in the variable -- which is why the same int[] variable can point to a new int[3] and then later point to an int[5], etc. What this means for the "Array of arrays" example above is that you are storing an array of memory addresses for int arrays. They are called "jagged" because each "array in the array" might be a different size (because you are just storing their addresses). This also means that you can mix things up like so:

Code:
int[][] arr = new int[][] {
   array1,          // This element in the array is the address of array1
   new int[]{1,2},  // The element is the address of a new int array
   new int[7],     // ...So is this one
   null           // "no address" (represented internally as 0)
};

A "rectangular" array is like an array of arrays, except that the actual arrays are themselves are stored within an array, rather than just their addresses. For this, you provide all the dimensions (size) of the array in one place rather than giving each "inner" array its own size (hence "jagged"). These are more efficient if you want to store static data all in one place without having to go through references of references, etc. Example:

Code:
int[,] rect1, rect2; // All are "rectangular" arrays of int
rect1 = new int[,] { // One new 3x6 "rectangle" of 18 ints
   { 0, 1, 2, 3, 4, 5},
   {10,11,12,13,14,15},
   {20,21,22,23,24,25}
};
rect2 = new int[6,7]; // A new 6x7 array (no values given)
rect2[3,3] = rect1[0,3]; // resulting value is 3

I belive you can combine them as well to have an array of rectangular arrays (int[][,]) or a rectangular array of arrays (int[,][]), etc. You can even add more dimensions, like a 3-dimensional array (int[,,]).
tifreak8x wrote:
What is the empty [] indicate?


Same thing it does in C++ - that you don't know the size. It's just a reference to an array after all, not the array itself - doesn't matter what the size is, that's only needed when you new one up.
Kllrnohj wrote:
tifreak8x wrote:
What is the empty [] indicate?


Same thing it does in C++ - that you don't know the size. It's just a reference to an array after all, not the array itself - doesn't matter what the size is, that's only needed when you new one up.


I'm jumping into this without any knowledge of any form of C.

Also, made it through while, do and for loops. so much fun.
Arrays have a fixed size, so if you're just creating a new blank array, you need to give it dimensions (like a number in the brackets):
Code:
int[] foo = new int[6]();
But if the data is already defined, the compiler can count how many elements there are for you, so you can leave the dimensions out:
Code:
int[] bar = new int[6] { 1, 1, 2, 3, 5, 8 } ;
(I haven't done C# in a few months, so hopefully my syntax is right.)
Presumably, now that 4 people have explained it to him and he's said he gets it and has moved on to other chapters, he gets it.

Quote:
Also, made it through while, do and for loops. so much fun.
So what's next on the list? Any cute starter programs you've written yet that you care to share?
Nothing out of what the tutorials have offered up.

I did adjust the while loop program to go to 5000 so I could see it displaying the data to the console window. That was kind of fun. Otherwise, I don't think enough has been learned at this point for me to attempt much of anything, yet.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
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

 

Advertisement