I've been digging into a decent book on Microsoft Visual C# 2008 by Patrice Pelland, and I really like the format of the book, as it's very hobby-programmer friendly. Not too many scary concepts or heavy coding, but rather a very visually-oriented spin through the basics of working with this particular IDE.
I'd like to check out some other titles in this series, as I think they have a good thing here for those who are still getting their feet wet in the coding world. And again the inclusion of a lot of visual images, to make sure that you are seeing what you are supposed to be seeing, is a nice touch.
Here are some of the first few programs that I put together, posted here mostly as a reference for me to revisit if needed:
Console application example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyFirstConsoleApplication
{
class Program
{
static void Main(string[] args)
{
// declaring two ingeger variables that will hold
// the two parts of the sum and one integer variable to
// hold the sum;
int number1;
int number2;
int sum;
// Assigning two values to the integer variables
number1 = 10;
number2 = 5;
// adding the two integers and storing the result in the
// sum variable
sum = (number1 + number2);
// displaying a string with the two numbers and the result.
Console.WriteLine("The sum of " + number1.ToString() + " and " + number2.ToString() + " is " + sum.ToString());
}
}
}
Window Application example:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MyFirstWindowApplication
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// declaring two ingeger variables that will hold
// the two parts of the sum and one integer variable to
// hold the sum;
int number1;
int number2;
int sum;
// Assigning two values to the integer variables
number1 = 10;
number2 = 5;
// adding the two integers and storing the result in the
// sum variable
sum = (number1 + number2);
// displaying a string with the two numbers and the result.
MessageBox.Show("The sum of " + number1.ToString() + " and " + number2.ToString()
+ " is " + sum.ToString() + ".");
}
}
}
No comments:
Post a Comment